Reputation: 8147
For iOS lower than 10 we used to have the property to get the types (.alert, .badge etc) of notifications User allowed. We used this code:
UIApplication.shared.currentUserNotificationSettings?.types
But it's now deprecated.
Question:
How can we do the same but using UNUserNotificationCenter
for ios10/11?
Is there an equivalent method?
Consider: the deprecated way still works but we never know if one day Apple will take it down.
Thanks in advance!
Upvotes: 1
Views: 308
Reputation: 5259
You can still get the notification settings by:
UNUserNotificationCenter.current().getNotificationSettings { settings in
if settings.alertSetting == .enabled {
//alert is enabled
}
}
As it's mentioned in apple doc
When the value of this property is UNNotificationSetting.enabled, the app is authorized to display alerts.
Upvotes: 2