Duck
Duck

Reputation: 35953

Knowing if an app is authorized to receive push notifications on-the-fly

Consider this situation. The app runs and application:didRegisterForRemoteNotificationsWithDeviceToken: receives information that the app is authorized to receive push notifications.

User puts app to background and removes app's authorization to receive notifications on the device's configuration.

User runs app again. Returning from background, the app still thinks it has authorization to receive push notifications. Neither application:didRegisterForRemoteNotificationsWithDeviceToken: or application:didFailToRegisterForRemoteNotificationsWithError: receives anything at this point.

Is there a way to know at any given point if an app has authorization to receive push notifications (reading something from device's notification preferences)?

thanks.

Upvotes: 2

Views: 1991

Answers (1)

w____
w____

Reputation: 3605

You can check for [[UIApplication sharedApplication] enabledRemoteNotificationTypes] each time the app returns from background.

See: iOS - Check for push notification support in the app

Once I have verified that the user has it disabled is there a way to programmatically direct the user to the notification settings on the device's configuration?

No for newer iOS versions. According to Navigate to settings screen in iphone and iOS Launching Settings -> Restrictions URL Scheme, you can use -[[UIApplication sharedApplication] openURL:] to navigate to settings screen, but only on devices running iOS version 5.0 and prior.

Upvotes: 5

Related Questions