使用iOS 10中的UNNotificationSettings检查通知类型

问题描述 投票:7回答:1

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

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

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

Bool active = notificationSettings.types == UIUserNotificationTypeNone ? NO: YES;
ios cocoa-touch ios10 usernotifications
1个回答
7
投票

我希望你问这个问题

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
}]
© www.soinside.com 2019 - 2024. All rights reserved.