我最近将我的iOS应用程序版本1.0更新为2.0版,推送通知无法按预期工作 .

在版本1.0中,我要求用户允许我需要设置应用程序图标徽章值的 UIUserNotificationTypeBadge 类型的通知 . 但是,我只在本地设置徽章值,因此没有涉及的远程通知 .

在2.0版本中,我现在想要使用远程通知来通知用户某些事件 . 因此,在AppDelegate中我注册了 UIUserNotificationSettings 的所有可用类型:

if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
    {
        // iOS 8 Notifications
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound) categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    }
    else
    {
        // iOS < 8 Notifications
        UIRemoteNotificationType types = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:types];
    }

我现在在2.0版中面临的问题是我在代理 -(void)application:didRegisterUserNotificationSettings: 中获得的notificationSettings被设置为app version 1.0中的旧设置 . (我只得到 UIUserNotificationsTypeBadge

此外,版本2.0中不会有任何提示要求用户提供通知权限 . 而奇怪的是,在设置中选择了通知样式 Banner . (见下图)

我还发现,为应用程序打开和关闭通知切换来自旧应用程序的设置,我在_1858171中获得了预期的用户通知设置 - > UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound

Notification Settings of the app

是否有人面临同样的问题,并找到了一个解决方案如何以编程方式覆盖旧的通知设置,而无需在设置中手动切换通知的开关?

任何帮助将非常感谢!

谢谢!