推送通知徽章不会在Urban Airship的后台更新

Sta*_*org 2 push-notification badge urbanairship.com ios

我一直在努力寻找一些似乎应该"正常工作"一段时间的事情.我通过Urban Airship建立了推送通知,除了应用程序在后台的徽章更新外,一切正常.据我所知,只要将徽章设置为有效负载中的整数,如果应用程序不在前台,这应该自行处理.

如果我在应用程序位于前台时捕获徽章更新,我可以正确设置它,但这不是我想在我的应用程序中使用徽章的原因.

这是我的设置 didFinishLaunchingWithOptions:

UAConfig *config = [UAConfig defaultConfig];

    // You can also programatically override the plist values:
    // config.developmentAppKey = @"YourKey";
    // etc.

    // Call takeOff (which creates the UAirship singleton)
    [UAirship takeOff:config];
    [UAPush shared].notificationTypes = (UIRemoteNotificationTypeBadge |
                                         UIRemoteNotificationTypeSound |
                                         UIRemoteNotificationTypeAlert |
                                        UIRemoteNotificationTypeNewsstandContentAvailability);

        [[UAPush shared] setPushEnabled:YES];

    [[UAPush shared] setAutobadgeEnabled:YES];
    [self performSelector:@selector(resetUABadge:)];
    [[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
                       applicationState:application.applicationState];
Run Code Online (Sandbox Code Playgroud)

当应用程序启动时,resetUABadge调用只会将所有内容设置回0.无论performSelector是否存在,此问题都会持续存在.

我不确定是否有一些我缺少的配置或者什么,但推送通知的其他部分在应用程序背景/关闭(警报,声音)时有效,但徽章根本不会更新.

Sta*_*org 5

我通过这个问题找到答案.如果您注册两者UIRemoteNotificationTypeBadge并且UIRemoteNotificationTypeNewsstandContentAvailability报摊类型完全打破徽章,则结果证明.不可否认,我本来就不应该首先在报摊上注册,但我从没想过会破坏徽章.

叹.