Upgrade Guide to FCM: Android¶
As announced by google, the support for GCM will end at 2019/4/11. Therefore in case you are still using GCM, it is recommended to follow the FCM transition procedure described below soon.
Transition procedure¶
Transition of a Google Cloud Platform project to the Firebase Console¶
From your Firebase Console create a new project and select your former GCM project:

Please confirm that your Google Cloud Platform project number and your Cloud Messaging sender ID are Identical. You can find your Project number under Google Cloud Platform > IAM & admin > Settings
The sender ID can be found in your Firebase Console under Settings(icon) > Cloud Messaging:
Setup FCM¶
Refer the steps in Register the App to download the
google-services.json
.Refer the steps in Generate Private Key and Register Server Key on Repro to register your Server Key.
Updating of the Repro Android SDK¶
Open your app/build.gradle
and upgrade the repro-android-sdk
to at least 3.1.1.
dependencies {
...
- implementation 'io.repro:repro-android-sdk:3.0.0'
+ implementation 'io.repro:repro-android-sdk:3.1.1'
...
}
Installation of the Firebase SDK¶
Copy
google-services.json
to the directory of app module.Please modify your projects
build.gradle
to accommodate for the following changes:buildscript { ... dependencies { ... + classpath 'com.google.gms:google-services:4.2.0' } } allprojects { ... repositories { ... + google() } }
Also modify your apps
build.gradle
to accommodate for the following changes:dependencies { - implementation 'com.google.android.gms:play-services-gcm:15.0.1' + implementation 'com.google.firebase:firebase-core:16.0.4' + implementation 'com.google.firebase:firebase-messaging:17.3.4' ... } +apply plugin: 'com.google.gms.google-services'
Also modify your AndroidManifest.xml as instructed below¶
Change io.repro.android.GCMReceiver
to io.repro.ReproReceiver
like this:
<receiver
- android:name="io.repro.android.GCMReceiver"
+ android:name="io.repro.android.ReproReceiver"
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>
Registration ID acquisition method related changes¶
Remove the argument from
Repro.enablePushNotification
as shown below:import io.repro.android.Repro; public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); ... Repro.setup(this, "YOUR_APP_TOKEN"); - Repro.enablePushNotification("SENDER_ID"); + Repro.enablePushNotification(); ... } }
Please call
Repro.setPushRegistrationID
in youronNewToken
method of your class that extendsFirebaseMessagingService
.import io.repro.android.Repro; public class MyFirebaseMessagingService extends FirebaseMessagingService { ... @Override public void onNewToken(String token) { Repro.setPushRegistrationID(token); } ... }
Then add this service configuration into your
AndroidManifest.xml
's<application>
tag:<service android:name=".MyFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
Custom Receiver¶
Continuing the use of a already implemented custom receiver¶
In case you are already using a custom receiver you are able to continue using that after the transition to FCM. You will have to change the name from GCMReceiver
to ReproReceiver
where your class extends the custom receiver.
-public class Receiver extends io.repro.android.GCMReceiver {
+public class Receiver extends io.repro.android.ReproReceiver {
@Override
public void onReceive(Context context, Intent intent) {
...
Transfer a custom receiver to FirebaseMessagingService¶
Please refer to the steps below in order to transfer your custom receiver to FirebaseMessagingService.
First delete your already existing custom receiver from your
AndroidManifest.xml
.<receiver android:name="your.package.name.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>
Replace "YOUR_PACKAGE_NAME" in the XML fragment below and add it inside the
<application>
tag.<receiver android:name="io.repro.android.ReproReceiver" 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>
Note
Even after transitioning to FCM, receivers must be registers in your AndroidManifest.
Please refer to customize the behavior when receiving messages in order to implement the
onMessageReceived
method of yourFirebaseMessagingService
.