Repro - Mobile Analytics for growth
日本語
Sign Up Back to Dashboard
  • System Requirements
  • Dashboard Guide
  • Development Guide
  • Release Notes
    • SDK
    • Web
    • Domain change related tasks
    • FCM transition procedure
      • Android
        • Transition procedure
          • Transition of a Google Cloud Platform project to the Firebase Console
          • Setup FCM
          • Updating of the Repro Android SDK
          • Installation of the Firebase SDK
          • Also modify your AndroidManifest.xml as instructed below
          • Registration ID acquisition method related changes
          • Custom Receiver
      • Unity
      • Cordova
      • Monaca
      • Cocos2d-x
  • FAQ

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:

../../_images/1-1-ImportGCMProject.en.png
  • 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

    ../../_images/1-2-GCMProjectID.en.png
  • The sender ID can be found in your Firebase Console under Settings(icon) > Cloud Messaging:

    ../../_images/1-3-FCMSenderID.en.png

Setup FCM¶

  1. Refer the steps in Register the App to download the google-services.json .

  2. 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¶

  1. Copy google-services.json to the directory of app module.

  2. 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()
         }
     }
    
  3. 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¶

  1. 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();
    
             ...
         }
     }
    
  2. Please call Repro.setPushRegistrationID in your onNewToken method of your class that extends FirebaseMessagingService.

        import io.repro.android.Repro;
    
        public class MyFirebaseMessagingService extends FirebaseMessagingService {
            ...
            @Override
            public void onNewToken(String token) {
                Repro.setPushRegistrationID(token);
            }
            ...
        }
    
  3. 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.

  1. 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>
    
  2. 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.

  3. Please refer to customize the behavior when receiving messages in order to implement the onMessageReceived method of your FirebaseMessagingService.

  • « FCM transition procedure
  • Upgrade Guide to FCM: Unity »

About Us Careers Terms of Service Privacy Policy Cookie Policy

© 2022 Repro Inc.