Reputation: 754
In ios 10 there is UNUserNotificationCenter
class and method getNotificationSettingsWithCompletionHandler
which gives you UNNotificationSettings
object and you can check is user has been ever asked for push notifications permissions.Is there a way to achieve this for iOS 9 and iOS 8.
Upvotes: 1
Views: 218
Reputation: 754
There is no way. That functionality is available starting from ios 10.
Upvotes: 0
Reputation: 10205
You can use something like this:
let notificationType = UIApplication.sharedApplication().currentUserNotificationSettings()!.types
if notificationType == UIUserNotificationType.None {
// Push notifications are disabled in setting by user.
} else {
// Push notifications are enabled in setting by user.
}
if notificationType != UIUserNotificationType.None {
// Push notifications are enabled in setting by user.
}
if notificationType == UIUserNotificationType.Badge {
// the application may badge its icon upon a notification being received
}
if notificationType == UIUserNotificationType.Sound {
// the application may play a sound upon a notification being received
}
if notificationType == UIUserNotificationType.Alert {
// the application may display an alert upon a notification being received
}
Upvotes: 1