iosapple-push-notificationslocalytics

Localytics ios push device token


I have implemented iOS push notifications with Localytics, and it is working, but I am confused about how they are capturing the deviceToken.

The documentation instructs me to call registerForRemoteNotifications to get the device token. Fine, this is standard. However the documentation is silent on how to handle the application delegate callback didRegisterForRemoteNotificationsWithDeviceToken. I assumed that I would need to call the class method in the SDK called setPushToken once the token was returned. This would be the logical thing to do. However, it seems to work without any code in didRegisterForRemoteNotificationsWithDeviceToken. Are they somehow intercepting this application delegate message and passing the token to their server? Is this the intended behavior? If so, what is the purpose of setPushToken in the SDK?


Solution

  • in v 4.1 it seems they're proxying the AppDelegate with one of their own. From their autoIntegrate(appKey: String, launchOptions: [NSObject : AnyObject]?) documentation:

    Use this method to automatically integrate the Localytics SDK in a single line of code. Automatic integration is accomplished by proxing the AppDelegate and "inserting" a Localytics AppDelegate behind the applications AppDelegate. The proxy will first call the applications AppDelegate and then call the Localytics AppDelegate.

    If you don't use SDK's autointegration, your supposed to call all methods by yourself, including setPushToken

    However, it seems some callbacks are not properly getting called, for example I'm getting no didRegisterForRemoteNotificationsWithDeviceToken at all, and I can't set any push token on other SDKs. If I remove the autointegration, everything is working as expected.