7

I have integrated the Localtyics iOS SDK. After this I am getting the error like below: Could not cast value of type 'LLAppDelegateProxy'

It means I am unable to get a reference of the App delegate object. I am in trouble now because I want Localytics & want a reference object of App delegate as well.

Does any body know a solution of this?

JAL
  • 41,701
  • 23
  • 172
  • 300
user3347272
  • 167
  • 1
  • 8
  • I got the solution. Localytics has provided solution in their documentation.https://docs.localytics.com/dev/ios.html#analytics-callbacks-ios – user3347272 Jun 20 '16 at 06:45
  • Maybe their documentation changed - the link that should get you right to this is https://help.uplandsoftware.com/localytics/dev/ios.html#swift-ios – spig Sep 02 '20 at 22:09

1 Answers1

12

Localytics replaces your AppDelegate behind-the-scenes with their proxy class (LLAppDelegateProxy). Localytics suggests creating a static reference to your original AppDelegate for access like so:

class AppDelegate: UIResponder, UIApplicationDelegate {
    static var originalAppDelegate: AppDelegate!

    // ...

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        AppDelegate.originalAppDelegate = self

        // ...

}

Access using:

AppDelegate.originalAppDelegate.someMethod()
JAL
  • 41,701
  • 23
  • 172
  • 300
  • this helped me thanks , but I am facing issue in LoginWithFacebook functionality as Localytics replaces AppDelegate behind-the-scenes with their proxy class (LLAppDelegateProxy) , my openURL method from AppDelegate doesn't call (It works fine if I remove the Localytics from my project ) – Vivek Shah Jun 15 '17 at 08:58
  • @VivekShah You should ask a new question. – JAL Jun 15 '17 at 11:40