我正在尝试实施application:didRegisterUserNotificationSettings:
App Delegate方法,以尝试确定是否允许我向iOS 8中的用户发送本地通知。以下是我尝试的方法实现,但这显然是不正确的方式。
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
if (notificationSettings.types /*How do i check which types are contained */) {
NSLog(@"Allowed");
} else {
NSLog(@"Not Allowed");
}
}
答案 0 :(得分:23)
你去吧
if (notificationSettings.types == UIUserNotificationTypeNone) {
NSlog(@"Permission not Granted by user");
}
else{
NSlog(@"Permission Granted");
}
询问特定设置:
BOOL allowsSound = (notifSettings.types & UIUserNotificationTypeSound) != 0;