Migrating to FCM

Batch 1.12 brings full FCM support.
While new integrations will automatically use it, applications that already used Batch require some changes to explicitly opt-in to a FCM migration. We strongly recommend that you update your app as soon as possible.

This documentation describes how to perform this migration.

Adding Firebase to your project

First, you'll need to make sure that Firebase is fully integrated into your application.

If not, you can follow Firebase's Get Started guide.
You can also use Android Studio:

  • Open the "Tools" menu, and select "Firebase"
  • In the panel that opened, select "Cloud Messaging", and click on "Set up Firebase Cloud Messaging"
  • Follow the steps "Connect your app to Firebase" and "Add FCM to your app". Batch already handles the next steps for you.

Your build.gradle should contain at least firebase-core and firebase-messaging:

implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'

Finally, make sure you updated Batch to 1.12 or higher.

Removing deprecated manifest entries

From your Android manifest please remove, if present, the following items:

  • BatchPushService
  • BatchPushReceiver
  • BatchPushInstanceIDService
<application>
    <service android:name="com.batch.android.BatchPushService" />
    <receiver android:name="com.batch.android.BatchPushReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        [...]
    </receiver>

    <service android:name="com.batch.android.BatchPushInstanceIDService" android:exported="true">
        <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID"/>
        </intent-filter>
    </service>
</application>

Removing old GCM Sender ID

Finally, open up your Application subclass, and delete your Batch.Push.setGCMSenderID() call.
The Sender ID is now read directly from Firebase's configuration.

Testing it

Once you've done this, the log with your registration ID should change, and say that it is using FCM:

Batch.Push: Registration ID/Push Token (FCM): <your device token>

If you see GCM instead of FCM or an error, please try to follow the documentation again, or contact us.