> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration from 4.x to 5.x (One time activity)

> Migrate your MoEngage Android SDK integration from version 4.x to 5.x with updated receivers and APIs.

Follow the installation steps mentioned [here](https://www.moengage.com/docs/developer-guide/android-sdk/sdk-integration/basic-integration/Install-Using-BOM).

Changes required to migrate to 5.x are minimum but some structural changes require you to remove some lines of code. This had to be done to make it loosely coupled and easy to integrate

* No change in Manifest permissions
* Basic integration points remain same
* Changes in receivers & services
* Deprecated few APIs and provided alternatives
* Inbox moved out of Main SDK and added to add-on lib

If using Play Services 7.3 **No Changes in the following receivers**.

<CodeGroup>
  ```XML XML wrap theme={null}
  {/*  MOENGAGE RECEIVER FOR RECEIVING GCM BROADCAST MESSAGES  */}
  <receiver
      android:name="com.moe.pushlibrary.PushGcmBroadcastReceiver"
      android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

          <category android:name="{YOUR_PACKAGE_NAME}" />
      </intent-filter>
  </receiver>
  {/*  MOENGAGE RECEIVER FOR RECEIVING INSTALLATION INTENT  */}
  <receiver android:name="com.moe.pushlibrary.InstallReceiver" >
      <intent-filter>
          <action android:name="com.android.vending.INSTALL_REFERRER" />
      </intent-filter>
  </receiver>
  ```
</CodeGroup>

If using Google Play Services 7.5

<CodeGroup>
  ```XML XML wrap theme={null}
  <receiver
      android:name="com.google.android.gms.gcm.GcmReceiver"
      android:exported="true"
      android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <category android:name="{YOUR_PACKAGE_NAME}" />
      </intent-filter>
  </receiver>
  <service
      android:name="com.moengage.worker.MoEGCMListenerService"
      android:exported="false" >
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
      </intent-filter>
  </service>
  <service
      android:name="com.moengage.receiver.MoEInstanceIDListener"
      android:exported="false">
      <intent-filter>
          <action android:name="com.google.android.gms.iid.InstanceID"/>
      </intent-filter>
  </service>
  ```
</CodeGroup>

# Remove the following receivers

<CodeGroup>
  ```Java Java wrap theme={null}
  {/*  MOENGAGE RECEIVER FOR RECEIVING PACKAGE UPDATED INTENT  */}
  <receiver android:name="com.moe.pushlibrary.PushUpdateReceiver" >
      <intent-filter>
          <action android:name="android.intent.action.PACKAGE_REPLACED" />
          <data
              android:path="{YOUR_PACKAGE_NAME}"
              android:scheme="package" />
      </intent-filter>
  </receiver>
  {/*  MOENGAGE SERVICE PROCESSING GCM MESSAGES  */}
  <service android:name="com.moe.pushlibrary.PushGCMIntentService" />
  {/*  MOENGAGE RECEIVER FOR INTERNAL PURPOSE  */}
  <receiver android:name="com.moe.pushlibrary.PushGcmRegister" />
  {/*  MOENGAGE RECEIVER FOR TRIGGERING INTERACTION DATA SYNC  */}
  <receiver android:name="com.moe.pushlibrary.SendReport" />
  ```
</CodeGroup>

# Add the following Receivers

<CodeGroup>
  ```XML XML wrap theme={null}
  <receiver android:name="com.moe.pushlibrary.AppUpdateReceiver" >
      <intent-filter>
          <action android:name="android.intent.action.PACKAGE_REPLACED" />
          <data
              android:path="{YOUR_PACKAGE_NAME}"
              android:scheme="package" />
      </intent-filter>
  </receiver>
  ```
</CodeGroup>

# Add the following Provider

<CodeGroup>
  ```XML XML wrap theme={null}
  <provider
      android:name="com.moe.pushlibrary.providers.MoEProvider"
      android:authorities="{YOUR_PACKAGE_NAME}.moengage.provider"
      android:exported="false" />
  ```
</CodeGroup>

# Add the \<meta> following tags

<CodeGroup>
  ```XML XML wrap theme={null}
  {/*  MANDATORY FIELD: APP ID AS SEEN ON MOENGAGE DASHBOARD APP SETTINGS PAGE  */}
  <meta-data
      android:name="APP_ID"
      android:value="DAO6UGZ73DXXTK7BXX96TPXX" />
  {/*  MANDATORY FIELD: SENDER ID , i.e. THE PROJECT NUMBER AS MENTIONED ON GOOGLE CLOUD CONSOLE PROJECTS PAGE  */}
  <meta-data
      android:name="SENDER_ID"
      android:value="id:687214452899" />

  {/*  MANDATORY FIELD: THE NOTIFICATION SMALL ICON WHICH WILL BE USED TO SET TO NOTIFICATIONS POSTED  */}
  <meta-data
      android:name="NOTIFICATION_ICON"
      android:value="@drawable/ic_launcher" />
  {/*  MANDATORY FIELD: THE NOTIFICATION LARGE ICON WHICH WILL BE USED TO SET TO NOTIFICATIONS POSTED  */}
  <meta-data
         android:name="NOTIFICATION_LARGE_ICON"
         android:value="@drawable/large_icon" />
  {/*  OPTIONAL FIELD: THE NOTIFICATION TYPE WHICH WILL BE USED, SINGLE OR MULTIPLE. DEFAULT BEHAVIOR IS SINGLE  */}
  <meta-data
      android:name="NOTIFICATION_TYPE"
      android:value="@integer/notification_type_multiple" />
  {/*  OPTIONAL FIELD: THE NOTIFICATION TONE THAT WILL BE USED. IF NOT SET WILL PLAY THE DEFAULT SOUND  */}
  <meta-data
      android:name="NOTIFICATION_TONE"
      android:value="@raw/tring" />
  ```
</CodeGroup>

# Delete the following code

<CodeGroup>
  ```Java Java wrap theme={null}
  //Delete the INITIALISATION METHOD CALL. THIS IS DEPRECATED AND NOT REQUIRED ANY LONGER
  helper.initialize( GCM_SENDER_ID, MOE_APP_ID);
  //Delete the REGISTER METHOD CALL. THIS IS DEPRECATED AND NOT REQUIRED ANY LONGER
  helper.Register(R.drawable.ic_launcher);
  ```
</CodeGroup>

# Add the following code (optional)

Add this only if you support the change in orientation.

<CodeGroup>
  ```Java Java wrap theme={null}
  /*
   * (non-Javadoc)
   * 
   * @see android.app.Activity#onSaveInstanceState(android.os.Bundle)
   */
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      mHelper.onSaveInstanceState(outState);
  }

  /*
   * (non-Javadoc)
   * 
   * @see android.app.Activity#onRestoreInstanceState(android.os.Bundle)
   */
  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
      mHelper.onRestoreInstanceState(savedInstanceState);
  }
  ```
</CodeGroup>

# Inbox Users

Change the following:

Old declaration

<CodeGroup>
  ```XML XML wrap theme={null}
  {/*  MOENGAGE INBOX ACTIVITY DECLARATION  */}
  <activity
      android:name="com.moe.pushlibrary.activities.MoEInboxActivity"
      android:label="@string/app_name" >
  </activity>
  ```
</CodeGroup>

Change to

<CodeGroup>
  ```XML XML wrap theme={null}
  <activity
      android:name="com.moengage.addon.inbox.MoEInboxActivity"
      android:label="@string/label_act_sec" >
  </activity>
  ```
</CodeGroup>

# Add the Install/Update Differentiator

Add the install update differentiator as mentioned [here](https://www.moengage.com/docs/developer-guide/android-sdk/data-tracking/basic/track-install-or-update).

In case you have any issues, please do contact the Custom Success Managers who will help you out
