【发布时间】:2020-09-19 01:13:05
【问题描述】:
我找不到解决方案,对此感到目瞪口呆。我有这个代码:
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
NSLog(@"%i %@",granted, error);
}];
然后它立即进入呼叫处理程序而不显示通知权限
2020-09-18 18:05:46.657991-0700 My App [404:9600] 0 Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application}
我错过了什么?警报甚至没有弹出。
注意:同样的代码在 iOS 13.x 上没有问题,在 iOS 14 上它立即失败。
【问题讨论】:
标签: ios notifications ios14 unusernotificationcenter