有了 CLAuthorizationStatus
,我可以确切地知道用户是否拒绝了应用程序权限(kCLAuthorizationStatusDenied
)或者状态是否未确定(kCLAuthorizationStatusNotDetermined
) .
...那么通知服务是否有类似的东西?我似乎找不到任何东西,而且似乎无法区分拒绝权限的用户和尚未显示权限弹出窗口的用户。
最佳答案
if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 8.0) {
UIUserNotificationSettings *current = [[UIApplication sharedApplication]currentUserNotificationSettings];
if (current.types != UIUserNotificationTypeNone){
NSLog(@"Notifications Enabled ios 8");
} else {
NSLog(@"Notifications not Enabled ios 8");
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication]enabledRemoteNotificationTypes];
if (types != UIRemoteNotificationTypeNone)
{
NSLog(@"Notifications Enabled");
}
else
{
NSLog(@"Notifications not Enabled");
}
}
关于iOS:有没有办法知道用户是否选择退出通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25929538/