Android GCM to FCM Migration

Migrate from Android GCM to FCM for continued enhancements and support.

Migrating from GCM to FCM

Google’s GCM services are deprecating as of April 1st, 2019, after which the support and further features improvements are not possible. As a replacement for GCM, google’s Firebase Cloud Messaging should be integrated with.

If you have already integrated with Gamooga’s GCM SDK, kindly follow the instructions below to migrate smoothly to FCM. And if you are already using FCM, you can skip this.

1. Adding Project as FCM project

  1. In the Firebase console, select Add Project.

  2. Select your GCM project from the list of existing Google Cloud projects, and select Add Firebase.

  3. In the Firebase welcome screen, select Add Firebase to your Android App.

  4. Provide your package name and SHA-1, and select Add App. A new google-services.json file for your Firebase app is downloaded.

2. Replacing GCM with FCM Dependencies

  1. Remove this line from your app/build.gradle :
     compile project(':gamooga-targetact-client-release')
    
  2. Check if this is already added if not add them
     compile "com.google.android.gms:play-services:+"
    
  3. Now add the Maven URL for Gamooga android-sdk. Add the following to the project build.gradle file:
     allprojects {
         repositories {
             jcenter()
             maven {
                 // add this line for gamooga repo, the above lines may already be there
                 url 'http://maven.gamooga.com:8081/artifactory/libs-release'
             }
         }
     }
    
  4. Add the following in the main application build.gradle file for FCM:
     compile "com.gamooga.targetact:gamooga-targetact-client:1.8.8.10"
    

3. Permissions

  1. Check If these permission are already added if not add them

     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    

Note: Gamooga does not need this permission anymore

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

4. Removing old Configurations

Replace the old Gamooga Configuration from AndroidManifest.xml with the new configuration.

Old GCM Configuration to be removed:

<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_app_id" />
    </intent-filter>
</receiver>
<service 
    android:name="com.gamooga.targetact.client.GamoogaGcmListenerService" 
    android:exported="false" />
    <intent-filter> 
        <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
    </intent-filter>
</service>
<service 
    android:name="com.gamooga.targetact.client.GamoogaInstanceIDListenerService" 
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID"/> 
    </intent-filter> 
</service>
<service 
    android:name="com.gamooga.targetact.client.RegistrationIntentService"
    android:exported="false">
</service>

Replace it with the New FCM configuration as below:

<service android:name="com.gamooga.targetact.client.fcmpush.GamoogaInstanceIDListenerService">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>
<service android:name="com.gamooga.targetact.client.fcmpush.GamoogaFCMListener">
    <intent-filter>
         <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

Additional Information

i. Deprecated Methods

The following had been deprecated from our SDK.

tac.getPushRegistrationId();
tac.saveSessionTimeout(int timeout);

ii. Changes

  1. ICallback is now called GamoogaCallback
  2. To get events the callback method is now onGetEvents
  3. For custom action the callback method is now onCustomActionReceived

iii. Additions

  1. If Client is using Gamooga FCM services

    GamoogaCallback call now have one more callback method to retrieve the push Messages as follows

     onPushMessageReceived(RemoteMessage message)
    
  2. If Client is using their own FCM services, Gamooga will bundle the push body into pending intent

    Whenever a user clicks on push notification, Client can retrieve the push body as below.

     getIntent().getBundleExtra("__push_body");
    
  3. For Oreo, we can create the Notification Channels & set priority.

    <meta-data android:name="GAMOOGA_PUSH_CHANNEL_NAME" android:value="Gamooga Custom" />
    <meta-data android:name="GAMOOGA_PUSH_CHANNEL_ID" android:value="gamooga_custom_id" />
    <meta-data android:name="GAMOOGA_PUSH_CHANNEL_DESCRIPTION" android:value="Gamooga Custom description" />
    <meta-data android:name="GAMOOGA_PUSH_CHANNEL_IMPORTANCE" android:value="3" />
    <meta-data android:name="PUSH_KEY_PROPERTY" android:value="my_app_push" />