Migrate from 3.0 to 3.1+

Use this guide if you have integrated the Localytics library 3.0 into your app and are ready to upgrade to 3.1.

To ensure proper initialization and push message tracking, we made several important changes in SDK 3.1. These changes require a few adjustments to how the SDK is integrated into your app. If you are migrating from 3.0, please follow the steps below to make the appropriate adjustments.

  1. If your integration is automatic, make the following changes.
    1. In your main Activity, remove the call to registerActivityLifecycleCallbacks() in the Activity's onCreate() method. This method call should be removed in all other Activity classes as well.
      public void onCreate(Bundle savedInstanceState)
      {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
       
         // Remove the next 2 lines
         getApplication().registerActivityLifecycleCallbacks(
               new LocalyticsActivityLifecycleCallbacks(this)); 
      }
    2. If you don't have a custom Application class, create one, and specify the name in your AndroidManifest.xml.
      <application
         android:name=".MyApplication"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name">
    3. In your Application's onCreate() method, register LocalyticsActivityLifecycleCallbacks.
      public class MyApplication extends Application
      {
         @Override
         public void onCreate()
         {
            super.onCreate();
       
            // Register LocalyticsActivityLifecycleCallbacks
            registerActivityLifecycleCallbacks(
                  new LocalyticsActivityLifecycleCallbacks(this));
         }
      }
  2. If your integration is manual, make the following changes.
    1. In your main Activity, remove the call to Localytics.integrate() in the Activity's onCreate() method. This method call should be removed in all other Activity classes as well.
      public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Remove this line Localytics.integrate(this); }
    2. If you don't have a custom Application class, create one, and specify the name in your AndroidManifest.xml.
      <application
         android:name=".MyApplication"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name">
    3. In your Application's onCreate() method, integrate Localytics.
      public class MyApplication extends Application
      {
         @Override
         public void onCreate()
         {
            super.onCreate();
       
            // Integrate Localytics
            Localytics.integrate(this);
         }
      }
  3. Add Google Play Services in your project for GCM support. More information on Play Services can be found here.
  4. Add the PushTrackingActivity to your AndroidManifest.xml. This Activity is used to track open rates for push notifications.
    <activity android:name="com.localytics.android.PushTrackingActivity"/>