Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check notification type using UNNotificationSettings in iOS 10

How can I use UNNotificationSettings to get the notification type in iOS 10?

On previous iOS, I would use this:

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

Bool active = notificationSettings.types == UIUserNotificationTypeNone ? NO: YES;
like image 698
Mehul Chuahan Avatar asked Sep 26 '16 10:09

Mehul Chuahan


1 Answers

I 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
}]
like image 185
Arun_ Avatar answered Nov 10 '22 10:11

Arun_