如何使用 UNNotificationSettings
获取 iOS 10 中的通知类型?
在以前的 iOS 上,我会使用这个:
UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
Bool active = notificationSettings.types == UIUserNotificationTypeNone ? NO: YES;
最佳答案
我希望你问的是这个
UNUserNotificationCenter.currentNotificationCenter().getNotificationSettingsWithCompletionHandler{ (mySettings) in mySettings.alertStyle == .None }
swift 4
UNUserNotificationCenter.current().getNotificationSettings{ (mySettings) in mySettings.alertStyle == .none }
对于 objective-c
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
settings.alertStyle == UNAlertStyleNone
}]
关于ios - 在 iOS 10 中使用 UNNotificationSettings 检查通知类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39700833/