로딩중입니다
[AOS] Live Operation 集成 : FCM Android
12/13/2017 5:11:59 PM
Live Operation FCM 服务

为了 Live Operation(简称 LiveOps) 和 Firebase Cloud Messaging(简称 FCM) 同时使用并初始化 LiveOps SDK 时,请参考如下步骤进行对接。


删除 LiveOps 初始化 API

以前在使用的 LiveOps 初始化 API,需设置注释或删除代码。

//IgawLiveOps.initialize(MainActivity.this); (删除以前在使用的 LiveOps 初始化 API)



定义 FCM API

在 FCM 的 onTokenRefresh() 上定义如下 API。 

package com.iga.AdbrixTestAppV1;
    
    import android.util.Log;
    
    import com.google.firebase.iid.FirebaseInstanceId;
    import com.google.firebase.iid.FirebaseInstanceIdService;
    import com.igaworks.liveops.IgawLiveOps;
    
    public class SDKDemoFirebaseInstanceIDService extends FirebaseInstanceIdService {
    
        private static final String TAG = "LiveOps";
    
        /**
         * Called if InstanceID token is updated. This may occur if the security of
         * the previous token had been compromised. Note that this is called when the InstanceID token
         * is initially generated so this is where you would retrieve the token.
         */
/* [START refresh_token] */ @Override public void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken); IgawLiveOps.registerFCMToken(getApplicationContext(), refreshedToken); } }



添加 Sender ID

在 google-services.json > project_number 上添加如下 LiveOps Sender ID。

{
    "project_info" : {
        "project_number" : "212616914444 , 910677924034",
        "project_id" : "sdkdemo-96c95" , 
        "storage_bucket" : "sdkdemo-96c95.appspot.com" ,
    }
}