Troubleshoot Push Messages Not Displayed on Android

If you encounter issues receiving messages in an app that uses the Salesforce Engagement SDK, consider these troubleshooting steps.

Check the SDK Logs 

  1. Enable logging in the SDK.

  2. Check the log for errors.

    The SDK provides verbose messages that are helpful in identifying and rectifying errors.

  3. To capture the log output from the SDK, add the MCLogListener interface.

    1// Enable SFMC logging
    2SFMCSdk.setLogging(LogLevel.DEBUG, LogListener.AndroidLogger())
    3
    4// Set Log Level
    5MarketingCloudSdk.setLogLevel(MCLogListener.VERBOSE)
    6
    7// Set Android Logcat Log Listener
    8MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener())
  4. Implement a custom log listener.

    1// Custom Logger implementation
    2class MyLogger : MCLogListener, LogListener {
    3    override fun out(level: Int, tag: String, message: String, throwable: Throwable?) {
    4        // level: VERBOSE, DEBUG, INFO, WARN, ERROR
    5        // Do something with the log output
    6    }
    7
    8    override fun out(level: LogLevel, tag: String, message: String, throwable: Throwable?) {
    9        // level: DEBUG, WARN, ERROR
    10        // Do something with the log output
    11    }
    12  }
    13
    14// Set Custom Log Listener
    15MarketingCloudSdk.setLogListener(MyLogger())

Send a Test Push 

To test whether your device can receive a push directly from FCM, follow these steps.

  1. Get the push token from the SDK.

    View code example for SDK version 8
    1SFMCSdk.requestSdk { sdk ->
    2  sdk.mp {
    3    it.pushMessageManager.pushToken?.let {
    4        token -> Log.d("TOKEN", token)
    5    }
    6  }
    7}
    View code example for SDK version 7
    1MarketingCloudSdk.requestSdk { sdk ->
    2  Log.d("TOKEN", sdk.pushMessageManager.pushToken)
    3}
  2. Use this script to send yourself a push message.

    1#!/usr/bin/env bash
    2export PUSH_TOKEN=#Use push token from SDK's PushMessageManager#getPushToken() method
    3export FCM_SERVER_KEY=#Use value from Firebase console
    4curl --header "Authorization: key=$FCM_SERVER_KEY" \
    5  --header Content-Type:"application/json" \
    6  https://fcm.googleapis.com/fcm/send \
    7  -d "{\"to\":\"$PUSH_TOKEN\",\"data\":{\"_m\":\"test_message\",\"alert\":\"It Worked!\",\"title\":\"Test Push\", \"_sid\":\"SFMC\"}}"

If your device successfully receives a message using the sample script but still can’t receive a message from Marketing Cloud Engagement, follow these steps.

  1. Wait 15 minutes after the first registration call for the device you’re testing with to ensure your device is properly registered in Engagement.
  2. Check the List you created in the Engagement UI and ensure the DeviceId you printed in Logcat shows up in the list.

For information about sending a test message in the Marketing Cloud Engagement, see Send a Test Message to Validate Accuracy.

Note

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.

Note

View code example for SDK version 8 and later
1if (BuildConfig.DEBUG) {
2
3  // Enable Logging _BEFORE_ calling the SDK's configure/init method
4  SFMCSdk.setLogging(LogLevel.DEBUG, LogListener.AndroidLogger())
5  MarketingCloudSdk.setLogLevel(VERBOSE)
6  MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener())
7
8  // When the SDK is ready, output its state to the logs
9  SFMCSdk.requestSdk {
10
11    // Specifically get the push state information
12    with(it.getSdkState()["PUSH"] as JSONObject) {
13
14      // General Troubleshooting
15      Log.i("~#SdkState", "initConfig: ${this["initConfig"]}")
16      Log.i("~#SdkState", "initStatus: ${this["initStatus"]}")
17      Log.i("~#SdkState", "PushMessageManager: ${(this["PushMessageManager"] as JSONObject).toString(2)}")
18      Log.i("~#SdkState", "RegistrationManager: ${(this["RegistrationManager"] as JSONObject).toString(2)}")
19
20      // Troubleshoot InApp Messages
21      Log.i("~#SdkState", "InAppMessageManager: ${(this["InAppMessageManager"] as JSONObject).toString(2)}")
22      Log.i(
23        "~#SdkState",
24        "InApp Messages: ${((this["InAppMessageManager"] as JSONObject)["messages"] as JSONArray).toString(2)}"
25      )
26
27      // Get Everything
28      Log.i("~#SdkState", "InApp Events: ${(this["Event"] as JSONObject).toString(2)}")
29    }
30  }
31}
View code example for SDK version 7
1if (BuildConfig.DEBUG) {
2
3  // Enable Logging _BEFORE_ calling the SDK's configure/init method
4  MarketingCloudSdk.setLogLevel(VERBOSE)
5  MarketingCloudSdk.setLogListener(MCLogListener.AndroidLogListener())
6
7  // When the SDK is ready, output its state to the logs
8  MarketingCloudSdk.requestSdk {
9
10    // Specifically get the push state information
11    with(it.sdkState) {
12
13      // General Troubleshooting
14      Log.i("~#SdkState", "initConfig: ${this["initConfig"]}")
15      Log.i("~#SdkState", "initStatus: ${this["initStatus"]}")
16      Log.i("~#SdkState", "PushMessageManager: ${(this["PushMessageManager"] as JSONObject).toString(2)}")
17      Log.i("~#SdkState", "RegistrationManager: ${(this["RegistrationManager"] as JSONObject).toString(2)}")
18
19      // Troubleshoot InApp Messages
20      Log.i("~#SdkState", "InAppMessageManager: ${(this["InAppMessageManager"] as JSONObject).toString(2)}")
21      Log.i(
22        "~#SdkState",
23        "InApp Messages: ${((this["InAppMessageManager"] as JSONObject)["messages"] as JSONArray).toString(2)}"
24      )
25
26      // Get Everything
27      Log.i("~#SdkState", "InApp Events: ${(this["Event"] as JSONObject).toString(2)}")
28    }
29  }
30}

When you debug push messaging, focus on the NotificationManager and PushMessageManager sections for key insights.

View code example for SDK version 8
1{
2  "sfmcSDKVersion": "1.0.2",
3  "PUSH": {
4    "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)",
5    "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)",
6    "RequestManager": {},
7    "AlarmScheduler": {
8      "pending_alarms": {}
9    },
10    "ControlChannel": {
11      "flag": "NONE"
12    },
13    "LocationManager": {
14      "geofencingEnabled": true,
15      "proximityEnabled": true,
16      "apiCode": 0,
17      "apiMessage": "SUCCESS",
18      "locationRequests": 0,
19      "locationsReceived": 0,
20      "geofenceEvents": 0
21    },
22    "ProximityManager": {
23      "proximityEnabled": true,
24      "enteredEvents": 0,
25      "exitedEvents": 0
26    },
27    "AnalyticsManager": {
28      "bet_analytics": true,
29      "et_analytics": true,
30      "pi_analytics": true,
31      "device_stats": true
32    },
33    "InboxMessageManager": {
34      "inbox_messages": "[]"
35    },
36    "NotificationManager": {
37      "notificationsEnabled": true,
38      "shouldShowNotificationListener": "com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces"
39    },
40    "RegionMessageManager": {
41      "geofenceMessagingEnabled": false,
42      "proximityMessagingEnabled": false,
43      "geofence_regions": "[]",
44      "geofence_region_messages": "[]",
45      "proximity_regions": "[]",
46      "proximity_region_messages": "[]",
47      "boot_complete_permission": true
48    },
49    "PushMessageManager": {
50      "pushEnabled": true,
51      "tokenRefreshListeners": [
52        "com.salesforce.marketingcloud.explorer.sdk.SdkModule$$ExternalSyntheticLambda1"
53      ],
54      "debugInfo": {
55        "senderId": "<redacted>",
56        "deviceToken": "<redacted>",
57        "firebaseApps": [
58          "FirebaseApp{name=[DEFAULT], options=FirebaseOptions{applicationId=1:<redacted>:android:<redacted>, apiKey=<redacted>, databaseUrl=null, gcmSenderId=null, storageBucket=null, projectId=et-public-demo-app}}"
59        ],
60        "c2dmReceiver": [
61          {
62            "name": "com.google.firebase.iid.FirebaseInstanceIdReceiver",
63            "priority": 0
64          }
65        ],
66        "instanceIdService": [],
67        "messagingService": [
68          {
69            "name": "com.salesforce.marketingcloud.messages.push.MCFirebaseMessagingService",
70            "priority": -1
71          },
72          {
73            "name": "com.google.firebase.messaging.FirebaseMessagingService",
74            "priority": -500
75          }
76        ]
77      }
78    },
79    "RegistrationManager": {
80      "current_registration": {
81        "deviceID": "18324364E1C9D141F1ABC9E8B33FC5938C5DA61B0E52AB8E434CBD202ED9BD93",
82        "device_Token": "<redacted>",
83        "sdk_Version": "8.0.5.0",
84        "app_Version": "8.0.5-SNAPSHOT.DEBUG : 23600000",
85        "dST": false,
86        "location_Enabled": false,
87        "proximity_Enabled": false,
88        "platform_Version": "12",
89        "push_Enabled": true,
90        "timeZone": "-18000",
91        "platform": "Android",
92        "hwid": "Google Pixel 4",
93        "etAppId": "<redacted>",
94        "locale": "en_US",
95        "tags": ["ALL", "Android", "DEBUG"],
96        "attributes": []
97      },
98      "last_sent_timestamp": "2022-03-09T18:10:41.107Z"
99    },
100    "InAppMessageManager": {
101      "messages": [],
102      "eventListener": "com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces",
103      "subscriberToken": "null",
104      "custom_font_set": false,
105      "status_bar_color": -13615201
106    },
107    "Event": {
108      "triggers": []
109    }
110  }
111}
View code example for SDK version 7
1{
2  "initConfig": "MarketingCloudConfig(applicationId=<redacted>, accessToken=<redacted>, senderId=<redacted>, marketingCloudServerUrl=http://localhost:39241/, mid=null, analyticsEnabled=true, geofencingEnabled=true, inboxEnabled=true, piAnalyticsEnabled=true, proximityEnabled=true, markMessageReadOnInboxNotificationOpen=true, delayRegistrationUntilContactKeyIsSet=false, useLegacyPiIdentifier=true, notificationCustomizationOptions={smallIconResId=2131230860, launchIntentProvider=com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces, channelIdProvider=com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces}, urlHandler=com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces@1133e7c, appPackageName=com.salesforce.marketingcloud.explorer.debug, appVersionName=7.4.4.DEBUG, predictiveIntelligenceServerUrl=https://app.igodigital.com/api/v1/collect/process_batch)",
3  "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)",
4  "RequestManager": {},
5  "AlarmScheduler": {
6    "pending_alarms": {}
7  },
8  "ControlChannel": {
9    "flag": "NONE"
10  },
11  "LocationManager": {
12    "geofencingEnabled": true,
13    "proximityEnabled": true,
14    "apiCode": 0,
15    "apiMessage": "SUCCESS",
16    "locationRequests": 0,
17    "locationsReceived": 0,
18    "geofenceEvents": 0
19  },
20  "ProximityManager": {
21    "proximityEnabled": true,
22    "enteredEvents": 0,
23    "exitedEvents": 0
24  },
25  "AnalyticsManager": {
26    "bet_analytics": true,
27    "et_analytics": true,
28    "pi_analytics": true,
29    "device_stats": true
30  },
31  "InboxMessageManager": {
32    "inbox_messages": "[]"
33  },
34  "NotificationManager": {
35    "notificationsEnabled": true,
36    "shouldShowNotificationListener": "com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces"
37  },
38  "RegionMessageManager": {
39    "geofenceMessagingEnabled": false,
40    "proximityMessagingEnabled": false,
41    "geofence_regions": "[]",
42    "geofence_region_messages": "[]",
43    "proximity_regions": "[]",
44    "proximity_region_messages": "[]",
45    "boot_complete_permission": true
46  },
47  "PushMessageManager": {
48    "pushEnabled": true,
49    "tokenRefreshListeners": [
50      "com.salesforce.marketingcloud.explorer.sdk.SdkModule$$ExternalSyntheticLambda1",
51      "com.salesforce.marketingcloud.explorer.sdk.SdkModule$$ExternalSyntheticLambda1"
52    ],
53    "debugInfo": {
54      "senderId": "<redacted>",
55      "deviceToken": "<redacted>",
56      "firebaseApps": [
57        "FirebaseApp{name=[DEFAULT], options=FirebaseOptions{applicationId=<redacted>, apiKey=<redacted>, databaseUrl=null, gcmSenderId=null, storageBucket=null, projectId=et-public-demo-app}}"
58      ],
59      "c2dmReceiver": [
60        {
61          "name": "com.google.firebase.iid.FirebaseInstanceIdReceiver",
62          "priority": 0
63        }
64      ],
65      "instanceIdService": [],
66      "messagingService": [
67        {
68          "name": "com.salesforce.marketingcloud.messages.push.MCFirebaseMessagingService",
69          "priority": -1
70        },
71        {
72          "name": "com.google.firebase.messaging.FirebaseMessagingService",
73          "priority": -500
74        }
75      ]
76    }
77  },
78  "RegistrationManager": {
79    "current_registration": {
80      "deviceID": "CECBFF7A84675A152774E60FDE7C461263DFF3957013B0771B39D89F2EA6D41B",
81      "device_Token": "<redacted>",
82      "sdk_Version": "7.4.4",
83      "app_Version": "7.4.4.DEBUG : 23240000",
84      "dST": false,
85      "location_Enabled": false,
86      "proximity_Enabled": false,
87      "platform_Version": "14",
88      "push_Enabled": true,
89      "timeZone": 19800,
90      "platform": "Android",
91      "hwid": "Google Pixel 7",
92      "etAppId": "<redacted>",
93      "locale": "en_US",
94      "tags": ["ALL", "Android", "DEBUG"],
95      "attributes": []
96    },
97    "last_sent_timestamp": "2024-04-22T07:45:35.509Z"
98  },
99  "InAppMessageManager": {
100    "messages": [],
101    "eventListener": "com.salesforce.marketingcloud.explorer.sdk.SdkInterfaces",
102    "subscriberToken": "<redacted>",
103    "custom_font_set": false,
104    "status_bar_color": -13615201
105  },
106  "Event": {
107    "triggers": []
108  }
109}

If you’ve implemented multiple push providers, review Troubleshoot Multiple Push SDKs for more information.

See Also