Check notification type using UNNotificationSettings in iOS 10

How can I use UNNotificationSettingsto get notification type in iOS 10?

In previous iOS, I would use this:

UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];

Bool active = notificationSettings.types == UIUserNotificationTypeNone ? NO: YES;
+4
source share
1 answer

Hope you are asking about this.

UNUserNotificationCenter.currentNotificationCenter().getNotificationSettingsWithCompletionHandler{ (mySettings) in  mySettings.alertStyle == .None }

Swift 4

UNUserNotificationCenter.current().getNotificationSettings{ (mySettings) in mySettings.alertStyle == .none }

For Objective-C

[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
    settings.alertStyle == UNAlertStyleNone
}]
+4
source

Source: https://habr.com/ru/post/1655819/


All Articles