2

I'm integrating AppsFlyer into my iOS Swift 4 app w/ XCode 10.0.

CocoPods has installed AppsFlyer 4.8.9 SDK.

import AppsFlyerLib works.

In didFinishLaunchingWithOptions, I can access AppsFlyerTracker.shared() and set the dev key & app id.

However, the 3rd line of code required for integration fails to compile. AppsFlyerTracker.shared().delegate = self

Error message: Cannot assign value of type 'AppDelegate' to type 'AppsFlyerTrackerDelegate?'

XCode's Suggestion: Insert ' as! AppsFlyerTrackerDelegate'

This suggestion does not work. The app crashes with the following error:

AppsFlyer SDK version 4.8.9 started build (728) Could not cast value of type 'MyApp.AppDelegate' (0x1057d0830) to >'AppsFlyerTrackerDelegate' (0x1056dcff8). 2018-10-27 18:17:49.448100-0700 Modacity[69104:7269920] Could not cast >value of type 'MyApp.AppDelegate' (0x1057d0830) to >'AppsFlyerTrackerDelegate' (0x1056dcff8).

Help? How do I set the delegate?

Thanks!

Marc Gelfo
  • 81
  • 8

1 Answers1

0

This message occurs because you have not yet conformed the class to the AppsFlyerTrackerDelegate protocol.

add AppsFlyerTrackerDelegate to the class conforming to the protocol if this is your main AppDelegate do this:

class AppDelegate: UIResponder, UIApplicationDelegate, AppsFlyerTrackerDelegate { ... }

The documentation should tell you which methods to implement after that...

It may be a good idea to review Protocols in the swift documentation and learn about Protocol orientated programing.

From the documentation: Image from AppsFlyer Docs

RLoniello
  • 2,309
  • 2
  • 19
  • 26