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
      • Unity
        • Transition procedure
          • Transition of a Google Cloud Platform project to the Firebase Console
          • Setup FCM
          • Updating of the Repro Unity Package
          • Installation of the Firebase SDK
          • Also modify your AndroidManifest.xml as instructed below
          • Registration ID acquisition method related changes
      • Cordova
      • Monaca
      • Cocos2d-x
  • FAQ

Upgrade Guide to FCM: Unity¶

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 Unity Package¶

Perform a SDK update to at least version 4.1.0 of the Repro Unity SDK according to Unity Package Upgrade Guide.

Installation of the Firebase SDK¶

Delete dependencies related to GCM¶

Please delete the file play-services-gcm-x.x.x.aar located at Assets/Plugins/Android/libs.

Import of the Firebase Unity Package¶

Refer to the official Firebase documentation and install FirebaseMessaging.unitypackage as well as FirebaseInstanceId.unitypackage.

Warning

In case you are using Repro Unity Package <= 6.5.0 or Firebase Cloud Messaging for Unity <= 7.2.0, then FirebaseInstanceId.unitypackage must be imported as well.

Warning

After installing the Firebase packages, the AndroidManifest.xml that you have setup in Specify Application Class should have been overwritten. Therefore you will have to once again adjust your AndroidManifest.xml file.

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¶

Obtain your FCM Registration ID via the method described here and pass it to Repro.SetPushRegistrationID(). Furthermore you must delete the first argument of Repro.enablePushNotification since it is GCM related and not needed anymore.

 using UnityEngine;

 public class MyBehaviour : MonoBehaviour {

     void Start () {
         ...

 #if UNITY_ANDROID
-        Repro.EnablePushNotification(SENDER_ID);
+        Repro.EnablePushNotification();
+        Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
+        Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
 #endif

         ...
     }

+#if UNITY_ANDROID
+    public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) {
+        Repro.SetPushRegistrationID(token.Token);
+    }
+
+    public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) {
+        ...
+    }
+#endif
 }
  • « Upgrade Guide to FCM: Android
  • Upgrade Guide to FCM: Cordova »

About Us Careers Terms of Service Privacy Policy Cookie Policy

© 2022 Repro Inc.