使用Xcode12(GM)进行构建时,
在检查完实现之后,似乎正在使用检查通知权限状态
的代码将其吐出
1 2 3 4 5 6 7 8 9 10 11 | UNUserNotificationCenter.current().getNotificationSettings { settings in switch settings.authorizationStatus { case .authorized, .provisional: print("許可") case .denied: print("拒否") case .notDetermined: print("許可求む") @unknown default: fatalError() } |
如果您查看
加入。
https://developer.apple.com/documentation/usernotifications/unauthorizationstatus
这个孩子是
换句话说,在可以从iOS14实现的应用剪辑中,您可以临时获得通知及其状态的权限。
如果您已实现了应用剪辑,请参考此官方参考资料
https://developer.apple.com/documentation/app_clips/enabling_notifications_in_app_clips
1 2 3 4 5 6 7 8 9 | let center = UNUserNotificationCenter.current() center.getNotificationSettings { (settings) in { if settings.authorizationStatus == .ephemeral { // The user didn't disable notifications in the app clip card. // Add code for scheduling or receiving notifications here. return } } |
添加类似
的内容。
如果未实现应用剪辑,则假定它不会通过,因此
1 2 3 4 5 6 7 8 9 10 11 12 13 | UNUserNotificationCenter.current().getNotificationSettings { settings in switch settings.authorizationStatus { case .authorized, .provisional: print("許可") case .denied: print("拒否") case .notDetermined: print("許可求む") case .ephemeral: fatalError()// or assertionFailure() @unknown default: fatalError() } |
您可以使用
避免该警告。
参考资料中包含beta,如果您不想使用
供您参考????