Karen  Karapetyan
Karen Karapetyan

Reputation: 754

Push notification not determined

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

Answers (2)

Karen  Karapetyan
Karen Karapetyan

Reputation: 754

There is no way. That functionality is available starting from ios 10.

Upvotes: 0

Sandro Machado
Sandro Machado

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

Related Questions