Troubleshooting Push Notifications

Check push notification status and fix common issues.

If push notifications aren’t working as expected, you can check the notification status to diagnose the issue. The SDK provides detailed information about their current state.

Get Current Notification Status

Read the current notification status from Airship.push.pushNotificationStatus to inspect each field:

Check notification status

val status = Airship.push.pushNotificationStatus

Log.d("Airship", "User notifications enabled: ${status.isUserNotificationsEnabled}")
Log.d("Airship", "Notifications allowed: ${status.areNotificationsAllowed}")
Log.d("Airship", "Privacy feature enabled: ${status.isPushPrivacyFeatureEnabled}")
Log.d("Airship", "Push token registered: ${status.isPushTokenRegistered}")
Log.d("Airship", "User opted in: ${status.isUserOptedIn}")
Log.d("Airship", "Fully opted in: ${status.isOptIn}")
PushNotificationStatus status = Airship.getPush().getPushNotificationStatus();

Log.d("Airship", "User notifications enabled: " + status.isUserNotificationsEnabled());
Log.d("Airship", "Notifications allowed: " + status.getAreNotificationsAllowed());
Log.d("Airship", "Privacy feature enabled: " + status.isPushPrivacyFeatureEnabled());
Log.d("Airship", "Push token registered: " + status.isPushTokenRegistered());
Log.d("Airship", "User opted in: " + status.isUserOptedIn());
Log.d("Airship", "Fully opted in: " + status.isOptIn());

Listen for Status Changes

Use the following to monitor notification status changes in real time:

Monitor notification status

scope.launch {
    Airship.push.pushNotificationStatusFlow.collect { status ->
        Log.d("Airship", "Notification status changed:")
        Log.d("Airship", "User opted in: ${status.isUserOptedIn}")
        Log.d("Airship", "Fully opted in: ${status.isOptIn}")
    }    
}
Airship.getPush().addNotificationStatusListener(status -> {
    Log.d("Airship", "Notification status changed:");
    Log.d("Airship", "User opted in: " + status.isUserOptedIn());
    Log.d("Airship", "Fully opted in: " + status.isOptIn());
});

Understanding Notification Status Fields

The NotificationStatus class provides detailed information about why push might not be working:

FieldDescription
isUserNotificationsEnabledWhether pushManager.userNotificationsEnabled is set to true
areNotificationsAllowedWhether the user has granted notification permissions
isPushPrivacyFeatureEnabledWhether the push privacy feature is enabled in PrivacyManager
isPushTokenRegisteredWhether a push token has been successfully registered with FCM
isUserOptedIntrue if user notifications are enabled, privacy feature is enabled, and notifications are allowed
isOptIntrue if isUserOptedIn is true AND a push token is registered

Common Status Scenarios

Status: isUserNotificationsEnabled = false

  • Cause: pushManager.userNotificationsEnabled has not been set to true.
  • Solution: Enable user notifications in your app code.

Status: areNotificationsAllowed = false

  • Cause: User denied notification permissions or permissions not yet requested. (Android 13+)
  • Solution: Request notification permissions or guide user to system settings.

Status: isPushPrivacyFeatureEnabled = false

  • Cause: Push privacy feature is disabled in Privacy Manager.
  • Solution: Enable the push privacy feature: UAirship.shared().privacyManager.setEnabledFeatures(PrivacyManager.Feature.PUSH).

Status: isPushTokenRegistered = false

  • Cause: Device hasn’t received a push token from FCM yet.
  • Solution: Check network connectivity, FCM configuration, and device/emulator limitations.

Status: isUserOptedIn = true but isOptedIn = false

  • Cause: Push token registration is pending or failed.
  • Solution: Check Logcat for FCM registration errors, verify network connectivity, and ensure proper FCM setup.