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

Upgrade Guide to FCM: Cocos2d-x¶

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 Retrieve Server Key and Register Server Key on Repro to register your Server Key.

Updating of the Repro Cocos2d-x SDK¶

Perform a SDK update to at least version 3.1.0 of the Repro Cocos2d-x SDK according to Cocos2d-x SDK Upgrade Guide.

Installation of the Firebase SDK¶

Delete dependencies related to GCM¶

 dependencies {
-     implementation "com.google.android.gms:play-services-gcm:15.0.1"
 }

Install the Firebase C++ SDK¶

Refer to the official Firebase documentation and install libfirebase_app.a as well as libfirebase_messaging.a.

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:

 // AppActivity.java
 package org.cocos2dx.cpp;

 import android.os.Bundle;
 import org.cocos2dx.lib.Cocos2dxActivity;
 import io.repro.android.Repro;

 public class AppActivity extends Cocos2dxActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        Repro.enablePushNotification();
-        Repro.enablePushNotification("SENDER_ID");
     }
 }

Then in your class that implements the firebase::messaging::Listener interface, the OnTokenReceived method should call ReproCpp::setPushRegistrationID.

#include "ReproCpp.h"

...

class MyFirebaseMessagingListener : public firebase::messaging::Listener {
...
public:
    void OnTokenReceived(const char* token) override {
        ReproCpp::setPushRegistrationID(token);
    }
  • « Upgrade Guide to FCM: Monaca
  • FAQ »

About Us Careers Terms of Service Privacy Policy Cookie Policy

© 2020 Repro Inc.