简体   繁体   English

ios:推送通知徽章数不会增加此有效负载格式

[英]ios : push notification badge count not increase in this payload formate

When application in background that time badge count not set last 5 days before is working properly. 在背景中申请时间标记计数未设置在最后5天之前正常工作。
Badge count every time increase by php backend ex. 每次通过php后端增加徽章计数。 Current badge = 10 then after second push get then badge = 11 当前徽章= 10然后在第二次推送之后获得徽章= 11


I am using bellow payload formate. 我正在使用波纹管有效载荷甲酸盐。
If any change in bellow formate then help me i read also refer Apple Push Notification Service. 如果波纹管甲酸盐有任何变化,那么帮助我阅读也请参考Apple推送通知服务。

push notification payload is a JSON payload: 推送通知有效负载是JSON有效负载:

{
    "aps": {
         "badge": 10,
         "alert": "Hello world!",
         "sound": "cat.caf"
    }
}


registerUserNotificationSettings registerUserNotificationSettings

if (ios8)
    {
        if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
            UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
            [[UIApplication sharedApplication] registerForRemoteNotifications];
        }
        else
        {
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
        }
    }
    else
    {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }

According to the description of payload keys from Apple documentation , the value associated with the key badge must be a number, so you can't increment the badge value from the payload (otherwise you couldn't differentiate a incrementation or a badge set to 1). 根据Apple文档中有效负载密钥的描述,与密钥徽章关联的值必须是数字,因此您无法从有效负载增加徽章值(否则您无法区分增量或徽章设置为1 )。

You can save the badge value server side and increment in on the server, so it will looks like an incrementation for the user. 您可以保存徽章值服务器端并在服务器上递增,因此它看起来像是用户的增量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM