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.notificationStatus to inspect each field:

Check notification status

let status = await Airship.push.notificationStatus

print("User notifications enabled: \(status.isUserNotificationsEnabled)")
print("Notifications allowed: \(status.areNotificationsAllowed)")
print("Privacy feature enabled: \(status.isPushPrivacyFeatureEnabled)")
print("Push token registered: \(status.isPushTokenRegistered)")
print("User opted in: \(status.isUserOptedIn)")
print("Fully opted in: \(status.isOptedIn)")
print("Display status: \(status.displayNotificationStatus)")
 Note

This async property is not available in Objective-C. Use the userPushNotificationsEnabled property and check authorization status directly with UNUserNotificationCenter.

Listen for Status Changes

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

Monitor notification status

Task {
    for await status in await Airship.push.notificationStatusUpdates {
        print("Notification status changed:")
        print("User opted in: \(status.isUserOptedIn)")
        print("Fully opted in: \(status.isOptedIn)")
    }
}
 Note

This async stream is not available in Objective-C. Use the userPushNotificationsEnabled property and check authorization status directly with UNUserNotificationCenter.

Understanding Notification Status Fields

The AirshipNotificationStatus struct provides detailed information about why push might not be working:

FieldDescription
isUserNotificationsEnabledWhether Airship.push.userPushNotificationsEnabled is set to true
areNotificationsAllowedWhether the user has granted notification permissions (at least one authorized type)
isPushPrivacyFeatureEnabledWhether the push privacy feature is enabled in AirshipPrivacyManager
isPushTokenRegisteredWhether a push token has been successfully registered with the system
displayNotificationStatusThe system permission status (.granted, .denied, .notDetermined, .ephemeral)
isUserOptedIntrue if user notifications are enabled, privacy feature is enabled, notifications are allowed, and display status is granted
isOptedIntrue if isUserOptedIn is true AND a push token is registered

Common Status Scenarios

Status: isUserNotificationsEnabled = false

  • Cause: Airship.push.userPushNotificationsEnabled 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.
  • 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: Airship.privacyManager.enabledFeatures = [.push].

Status: isPushTokenRegistered = false

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

Status: isUserOptedIn = true but isOptedIn = false

  • Cause: Push token registration is pending or failed.
  • Solution: Check console logs for APNs registration errors, verify network connectivity, and ensure proper entitlements.