Migrate from v2 to v3

Use this guide if you have integrated v2 of the Localytics library into your app and are ready to upgrade to v3.

Architecture updates allow us to quickly introduce new features without requiring backwards-incompatible changes. The v3 SDK supports

Changes to the method signatures make the iOS and Android Localytics SDKs almost identical. We've aligned the method signatures on iOS and Android, making it easier to keep your integrations up to date. The new method signatures also make development in new languages, such as Swift, and alternative platforms, such as Titanium, simpler.

Version 3 of the Localytics iOS SDK represents a substantial architectural change as well as a simplification of the API. Most notably, the API forgoes the singleton pattern utilized in v2 and instead makes use of class-level methods. This means that

[[LocalyticsSession shared] METHOD_NAME];

now becomes

[Localytics METHOD_NAME];
In addition, all methods which were previously part of
LocalyticsSession
and
LocalyticsAmpSession
are now available combined under Localytics.

Profiles data now defaults to an app-level scope. Previously all Profiles data defaulted to an org-level scope.

  1. Enable background push. Push reporting will not work well without it.
  2. Do a project-level regular expression replace of \[Localytics(Amp)?Session shared\] with Localytics.
  3. If you are tracking push, remove application:didReceiveRemoteNotification: if your application uses it and replace it with application:didReceiveRemoteNotification:fetchCompletionHandler:.
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
    {
        [Localytics handlePushNotificationOpened:userInfo];
        completionHandler(UIBackgroundFetchResultNoData);
    }
  4. If your integration is manual, and you use application:didReceiveRemoteNotification:fetchCompletionHandler:, be sure to remove the following code from your application delegate's application:didFinishLaunchingWithOptions: method.
    [[LocalyticsSession shared] handleRemoteNotification:[launchOptions objectForKey:
    UIApplicationLaunchOptionsRemoteNotificationKey]];