当推送通知中的应用程序处于非活动状态时,ios徽章不会更改

时间:2014-05-26 10:13:33

标签: ios apple-push-notifications badge

当我的应用程序处于非活动状态时,我想更改应用程序的徽章。当我的应用程序处于活动状态时徽章按<1>递增1

-(void)application:(UIApplication *)application didReceiveRemoteNotification:    (NSDictionary *)userInfo 
{    
    NSInteger badgeNumber = [application applicationIconBadgeNumber];

    [application setApplicationIconBadgeNumber:++badgeNumber];   
    NSInteger badgeNumber = [application applicationIconBadgeNumber];

    [application setApplicationIconBadgeNumber:++badgeNumber];
}

但是当我的应用程序处于非活动状态时。我读到操作系统会自动将徽章发送到有效负载中。 这是我的有效载荷:

{
    "aps": {
        "alert": "You have an image to view",
        "sound": "default",
        "badge": 2
    }
}

但徽章并没有改变。任何人都可以帮助我。

0 个答案:

没有答案