0

I am using this piece of code to find out if the user has accepted to receive Remote Notifications UIApplication.sharedApplication().isRegisteredForRemoteNotifications() - However, testing it on my device, even though I tapped "Don't Allow" - I get true and also I get the device token?

On the other hand, in the Settings app => Notifications the app is set not to receive any notifications...

So is there a correct way to find out if user has to has not allowed the app to receive APN?

Ahmed Khedr
  • 1,053
  • 1
  • 11
  • 24

1 Answers1

3

You can get the current notification settings with currentUserNotificationSettings:

let notificationSettings = UIApplication.sharedApplication().currentUserNotificationSettings()
print("Notification types allowed by user is: \(notificationSettings.types).")

If the user has disabled notifications, the types will be None.

Mats
  • 8,528
  • 1
  • 29
  • 35