推送通知不会立即更新

时间:2015-02-26 09:43:06

标签: ios iphone ios8 push-notification apple-push-notifications

我正在使用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

1 个答案:

答案 0 :(得分:0)

尝试在didRegisterUserNotificationSettings委托方法中进行检查,如下所示:

-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings
{
    UIUserNotificationSettings* currentSeting =  [[UIApplication sharedApplication] currentUserNotificationSettings];
}