# Troubleshooting Push Notifications

Check push notification status and fix common issues.

If [push notifications](https://www.airship.com/docs/developer/sdk-integration/apple/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:


#### Swift


```swift
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)")
```



#### Objective-C


> **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:


#### Swift


```swift
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)")
    }
}
```



#### Objective-C


> **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:

| Field | Description |
|-------|-------------|
| `isUserNotificationsEnabled` | Whether `Airship.push.userPushNotificationsEnabled` is set to `true` |
| `areNotificationsAllowed` | Whether the user has granted notification permissions (at least one authorized type) |
| `isPushPrivacyFeatureEnabled` | Whether the push privacy feature is enabled in `AirshipPrivacyManager` |
| `isPushTokenRegistered` | Whether a push token has been successfully registered with the system |
| `displayNotificationStatus` | The system permission status (`.granted`, `.denied`, `.notDetermined`, `.ephemeral`) |
| `isUserOptedIn` | `true` if user notifications are enabled, privacy feature is enabled, notifications are allowed, and display status is granted |
| `isOptedIn` | `true` 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.
