【问题标题】:Push notification doesn't update immediately推送通知不会立即更新
【发布时间】:2015-02-26 09:43:06
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-30
    • 2018-11-08
    • 1970-01-01
    • 2012-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多