I am in the process of updating to the latest Salesforce SDK 6.3.5(Also the same with 6.4.0,latest version) from our old sdk which used GCM.
I have gone through the steps as mentioned below: https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/
- The app was already provisioned. Updated the Google FCM server key with the Legacy server key.(This is just to ensure that we still have the right keys)
- App was already created on MobilePush portal
Followed these steps for upgrading to FCM:
Only few things to note :
- Already had Firebase integrated as we were using it for Remote Config and also for cloud functions. Since we have to make use of FirebaseMessagingService to handle the cloud function ping, went through this documentation relating to multiple PushSDK
- setSenderId is not set during initialisation phase.
- Used my own custom FirebaseMessagingService and followed the steps as mentioned in the article
End Results :
App deploys fine, but following things happens:
when onRegistrationReceived method is called, systemToken is always null i.e. registration.systemToken() returns null
Added all sorts of logging in app including SDKSTATE and log listener to print the details
From the logs, i find that the following message keeps appearing :
Message :Failed to retrieve InstanceId from Firebase.
Sdk Version: 6.3.5
Google Play Services Version: 12451000
2019-10-28 12:19:09.968 31636-31781/com.example.salesforce D/>>>: Throwable :Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken(java.lang.String, java.lang.String)' on a null object reference
Essentially due to above two issues i.e.
* Failed to retrieve InstanceId from Firebase.
* systemToken being null
The connection to FCM is somehow unsuccessful and hence onNewToken method of the custom FirebaseMesasagingService is never called.
Have been through this article as well:
In order to test this, we need the pushToken but since that is always null, cannot test it as well.
Have tested sending a push message from the MobilePush portal using the deviceId generated. But in this case, as well, the message is not received.
Some observations:
Are we supposed to use Legacy key always?(Since Google is advising against it)
Having multiple FirebaseMessagingService.I see that if i implement my own FirebaseMessagingService, from the SDKState logs, there are three including the superclass with different priority
"messagingService":[{"name":"com.example.salesforce.firebaseService.MyFirebaseService","priority":0},
{"name":"com.salesforce.marketingcloud.messages.push.MCFirebaseMessagingService","priority":-1},
{"name":"com.google.firebase.messaging.FirebaseMessagingService","priority":-500}]}},
Some logs that might help:
Listener logs during initialisation
2019-10-28 12:19:09.203 31636-31695/com.example.salesforce D/>>>: status usable:true 2019-10-28 12:19:09.203 31636-31695/com.example.salesforce D/>>>: status loc error :false 2019-10-28 12:19:09.787 31636-31636/com.example.salesforce D/>>>: Message :Unable to retrieve NotificationMessage from Intent (Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.salesforce/com.example.salesforce.view.splashScreen.SplashScreenActivity (has extras) }). Sdk Version: 6.3.5 Google Play Services Version: 12451000 2019-10-28 12:19:09.787 31636-31636/com.example.salesforcee D/>>>: Throwable :Attempt to get length of null array 2019-10-28 12:19:09.853 31636-31636/com.example.salesforce D/>>>: Token is : null
SDKSTATE logs with details of interest:
"PushMessageManager":{"pushEnabled":true,"debugInfo":{"senderId":"XXXXX","deviceToken":null,"firebaseApps":["FirebaseApp{name=[DEFAULT], options=FirebaseOptions{applicationId=1:XXX:android:XXX, apiKey=XXX, databaseUrl=XXX, gcmSenderId=XXX, storageBucket=XXX, projectId=XXX-XXX}}"],"c2dmReceiver":[{"name":"com.google.firebase.iid.FirebaseInstanceIdReceiver","priority":0}],"instanceIdService":[], "messagingService":[{"name":"com.example.salesforce.firebaseService.MyFirebaseService","priority":0}, {"name":"com.salesforce.marketingcloud.messages.push.MCFirebaseMessagingService","priority":-1}, {"name":"com.google.firebase.messaging.FirebaseMessagingService","priority":-500}]}}, "RegistrationManager":{"current_registration":{"deviceID":"XXX","sdk_Version":"6.3.5","app_Version":"X.X.X.X : XXX","dST":false,"location_Enabled":false,"proximity_Enabled":false,"platform_Version":"9","push_Enabled":true,"timeZone":0,"platform":"Android","hwid":"samsung SM-G975F","etAppId":"XXXX-XX","locale":"en_GB","tags":["ALL","Android"],"attributes":[]}},"InAppMessageManager":{"messages":[],"subscriberToken":"null","custom_font_set":false,"status_bar_color":0},"Event":{"triggers":[]}} 2019-10-28 12:19:09.910 31636-31636/com.example.salesforce D/>>>: Device id : XXXXX 2019-10-28 12:19:09.968 31636-31781/com.example.salesforce D/>>>: Message :Failed to retrieve InstanceId from Firebase. Sdk Version: 6.3.5 Google Play Services Version: 12451000 2019-10-28 12:19:09.968 31636-31781/com.example.salesforce D/>>>: Throwable :Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken(java.lang.String, java.lang.String)' on a null object reference