【问题标题】:Push notification badge doesn't update in background with Urban Airship推送通知徽章不会在 Urban Airship 的后台更新
【发布时间】:2013-09-01 22:16:09
【问题描述】:

一段时间以来,我一直在为似乎应该“正常工作”的事情苦苦挣扎。我通过 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];

resetUABadge 调用只是在应用启动时将所有内容设置回 0。无论 performSelector 是否存在,这个问题都存在。

我不确定我是否缺少某些配置或什么,但推送通知的所有其他部分在应用程序后台/关闭(警报、声音)时工作,但徽章根本不会更新。

【问题讨论】:

  • 我的应用在 [UAirship takeOff:config] 上显示错误的 Excess; 帮我解决这个问题。

标签: ios push-notification urbanairship.com badge


【解决方案1】:

我通过this question 找到了答案。事实证明,如果您同时注册 UIRemoteNotificationTypeBadgeUIRemoteNotificationTypeNewsstandContentAvailability,则报摊类型会完全破坏徽章。诚然,我一开始就不应该注册报摊,但我从没想过它会破坏徽章。

叹息。

【讨论】:

  • 很棒的发现!感谢您发布您的答案。我整天都在寻找这个谜题的答案!
猜你喜欢
  • 1970-01-01
  • 2012-09-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-24
  • 1970-01-01
相关资源
最近更新 更多