我正在使用iOS 8+上的推送通知。我尝试更新UIUserNotificationSettings值并将其恢复比较,但它不一样。有人可以帮我解决/解释这个问题。非常感谢。
这是我的代码:
UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
NSLog(@"Before register: %u", types);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
UIUserNotificationSettings* currentSeting = [[UIApplication sharedApplication] currentUserNotificationSettings];
NSLog(@"After register: %u", currentSeting.types);
这是输出控制台:
Before register: 6
After register: 0
答案 0 :(得分:0)
尝试在didRegisterUserNotificationSettings
委托方法中进行检查,如下所示:
-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings
{
UIUserNotificationSettings* currentSeting = [[UIApplication sharedApplication] currentUserNotificationSettings];
}