7

如何UNNotificationSettings在 iOS 10 中使用获取通知类型?

在以前的 iOS 上,我会使用这个:

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

Bool active = notificationSettings.types == UIUserNotificationTypeNone ? NO: YES;
4

1 回答 1

9

我希望你问这个

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

斯威夫特 4

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

对于 Objective-C

[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
    settings.alertStyle == UNAlertStyleNone
}]
于 2016-09-26T11:18:53.843 回答