Push Messages Not Displayed
If you encounter issues receiving messages in your app, consider these troubleshooting items:
Check the SDK’s log output
Enabling logging in the SDK and verify no errors are being logged.
Ensure you attempt this important debugging step. The SDK provides very verbose messages, and you can correct many errors and issues by reviewing the logcat.
Send a test push
Test that your device can receive a push directly from FCM.
- Get the push token from the SDK
SFMCSdk.requestSdk { sdk -> | |
sdk.mp { | |
it.pushMessageManager.pushToken?.let { | |
token -> Log.d("TOKEN", token) | |
} | |
} | |
} |
- Use this script to send yourself a push message
#!/usr/bin/env bash | |
export PUSH_TOKEN=#Use push token from SDK's PushMessageManager#getPushToken() method | |
export FCM_SERVER_KEY=#Use value from Firebase console | |
curl --header "Authorization: key=$FCM_SERVER_KEY" \ | |
--header Content-Type:"application/json" \ | |
https://fcm.googleapis.com/fcm/send \ | |
-d "{\"to\":\"$PUSH_TOKEN\",\"data\":{\"_m\":\"test_message\",\"alert\":\"It Worked!\",\"title\":\"Test Push\", \"_sid\":\"SFMC\"}}" |
- If you successfully receive a message using the sample script but still cannot to receive a message from the Marketing Cloud to your device, follow these steps:
- Wait 15 minutes after the first registration call for the device you’re testing with to ensure your device properly registered in the Marketing Cloud.
- Check the List you created in the Marketing Cloud and ensure the DeviceId you printed in the logcat shows up in the list.
Evaluate the SDK state
Look through the output from the Sdk’s getSdkState()
method.
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
Sometimes the output from the SDK's Get State method can exceed Android's output length | |
restrictions. | |
Adding an `indentSpaces` to the output of JSONObjects can help bypass this restriction. | |
Additionally, you can get each of the sections independently. | |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
if (BuildConfig.DEBUG) { | |
// Enable Logging _BEFORE_ calling the SDK's configure/init method | |
SFMCSdk.setLogging(LogLevel.DEBUG, LogListener.AndroidLogger()) | |
MarketingCloudSdk.setLogLevel(VERBOSE) | |
MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener()) | |
// When the SDK is ready, output its state to the logs | |
SFMCSdk.requestSdk { | |
// Specifically get the push state information | |
with(it.getSdkState()["PUSH"] as JSONObject) { | |
// General Troubleshooting | |
Log.i("~#SdkState", "initConfig: ${this["initConfig"]}") | |
Log.i("~#SdkState", "initStatus: ${this["initStatus"]}") | |
Log.i("~#SdkState", "PushMessageManager: ${(this["PushMessageManager"] as JSONObject).toString(2)}") | |
Log.i("~#SdkState", "RegistrationManager: ${(this["RegistrationManager"] as JSONObject).toString(2)}") | |
// Troubleshoot InApp Messages | |
Log.i("~#SdkState", "InAppMessageManager: ${(this["InAppMessageManager"] as JSONObject).toString(2)}") | |
Log.i( | |
"~#SdkState", | |
"InApp Messages: ${((this["InAppMessageManager"] as JSONObject)["messages"] as JSONArray).toString(2)}" | |
) | |
// Get Everything | |
Log.i("~#SdkState", "InApp Events: ${(this["Event"] as JSONObject).toString(2)}") | |
} | |
} | |
} |
There is a lot of information provided in this method, but for debugging push messaging you will want to look specifically at the NotificationManager and PushMessageManager sections.
{ | |
"sfmcSDKVersion": "1.0.2", | |
"PUSH": { | |
"initConfig": "MarketingCloudConfig(applicationId=<redacted>, accessToken=<redacted>, senderId=<redacted>, marketingCloudServerUrl=http:\/\/localhost:43683\/, mid=null, analyticsEnabled=true, geofencingEnabled=true, inboxEnabled=true, piAnalyticsEnabled=true, proximityEnabled=true, markMessageReadOnInboxNotificationOpen=true, delayRegistrationUntilContactKeyIsSet=false, useLegacyPiIdentifier=true, notificationCustomizationOptions={notificationBuilder=com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces}, urlHandler=com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces@6b985d4, appPackageName=com.salesforce.marketingcloud.explorer.debug, appVersionName=8.0.5-SNAPSHOT.DEBUG, predictiveIntelligenceServerUrl=https:\/\/app.igodigital.com\/api\/v1\/collect\/process_batch)", | |
"initStatus": "InitializationStatus(status=SUCCESS, unrecoverableException=null, locationsError=false, playServicesStatus=0, playServicesMessage=SUCCESS, encryptionChanged=false, storageError=false, proximityError=false, messagingPermissionError=false, sslProviderEnablementError=false, initializedComponents=[BehaviorManager, LifecycleManager, RequestManager, AlarmScheduler, SyncRoute, ControlChannel, LocationManager, ProximityManager, AnalyticsManager, InboxMessageManager, NotificationManager, RegionMessageManager, PushMessageManager, RegistrationManager, InAppMessageManager, Event], isUsable=true)", | |
"RequestManager": {}, | |
"AlarmScheduler": { | |
"pending_alarms": {} | |
}, | |
"ControlChannel": { | |
"flag": "NONE" | |
}, | |
"LocationManager": { | |
"geofencingEnabled": true, | |
"proximityEnabled": true, | |
"apiCode": 0, | |
"apiMessage": "SUCCESS", | |
"locationRequests": 0, | |
"locationsReceived": 0, | |
"geofenceEvents": 0 | |
}, | |
"ProximityManager": { | |
"proximityEnabled": true, | |
"enteredEvents": 0, | |
"exitedEvents": 0 | |
}, | |
"AnalyticsManager": { | |
"bet_analytics": true, | |
"et_analytics": true, | |
"pi_analytics": true, | |
"device_stats": true | |
}, | |
"InboxMessageManager": { | |
"inbox_messages": "[]" | |
}, | |
"NotificationManager": { | |
"notificationsEnabled": true, | |
"shouldShowNotificationListener": "com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces" | |
}, | |
"RegionMessageManager": { | |
"geofenceMessagingEnabled": false, | |
"proximityMessagingEnabled": false, | |
"geofence_regions": "[]", | |
"geofence_region_messages": "[]", | |
"proximity_regions": "[]", | |
"proximity_region_messages": "[]", | |
"boot_complete_permission": true | |
}, | |
"PushMessageManager": { | |
"pushEnabled": true, | |
"tokenRefreshListeners": [ | |
"com.salesforce.marketingcloud.explorer.sdk.SdkModule$$ExternalSyntheticLambda1" | |
], | |
"debugInfo": { | |
"senderId": "<redacted>", | |
"deviceToken": "<redacted>", | |
"firebaseApps": [ | |
"FirebaseApp{name=[DEFAULT], options=FirebaseOptions{applicationId=1:<redacted>:android:<redacted>, apiKey=<redacted>, databaseUrl=null, gcmSenderId=null, storageBucket=null, projectId=et-public-demo-app}}" | |
], | |
"c2dmReceiver": [ | |
{ | |
"name": "com.google.firebase.iid.FirebaseInstanceIdReceiver", | |
"priority": 0 | |
} | |
], | |
"instanceIdService": [], | |
"messagingService": [ | |
{ | |
"name": "com.salesforce.marketingcloud.messages.push.MCFirebaseMessagingService", | |
"priority": -1 | |
}, | |
{ | |
"name": "com.google.firebase.messaging.FirebaseMessagingService", | |
"priority": -500 | |
} | |
] | |
} | |
}, | |
"RegistrationManager": { | |
"current_registration": { | |
"deviceID": "18324364E1C9D141F1ABC9E8B33FC5938C5DA61B0E52AB8E434CBD202ED9BD93", | |
"device_Token": "<redacted>", | |
"sdk_Version": "8.0.5.0", | |
"app_Version": "8.0.5-SNAPSHOT.DEBUG : 23600000", | |
"dST": false, | |
"location_Enabled": false, | |
"proximity_Enabled": false, | |
"platform_Version": "12", | |
"push_Enabled": true, | |
"timeZone": "-18000", | |
"platform": "Android", | |
"hwid": "Google Pixel 4", | |
"etAppId": "<redacted>", | |
"locale": "en_US", | |
"tags": [ | |
"ALL", | |
"Android", | |
"DEBUG" | |
], | |
"attributes": [] | |
}, | |
"last_sent_timestamp": "2022-03-09T18:10:41.107Z" | |
}, | |
"InAppMessageManager": { | |
"messages": [], | |
"eventListener": "com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces", | |
"subscriberToken": "null", | |
"custom_font_set": false, | |
"status_bar_color": -13615201 | |
}, | |
"Event": { | |
"triggers": [] | |
} | |
} | |
} |
If you implement multiple push providers, review the Multiple Push SDKs page for additional information.