drkug66408 2015-05-18 14:26
浏览 108
已采纳

如何通过swift使用自己的php APNS服务器从推送通知中增加徽章号码?

Now I'm working on IOS app project by swift. So I need to increase badge number every time when the server push notification to the device. Right now it is always 1 badge no increasing.

This is my payload.

// Create the payload body
$body['aps'] = array(
    'alert' => $message,
    'sound' => 'default',
    'badge' => 1
    );
// Encode the payload as JSON
$payload = json_encode($body);
$messageId = $randomNotiId;

Thanks!

  • 写回答

1条回答 默认 最新

  • dongxi7722 2015-05-18 14:34
    关注

    You just need to save the badge number every time you push a notification and clear all if user sees them.

    You need to upload value to the server when seen and then when you push a notification to that user you can retrieve how many notification he/she has and use that number + 1.

    I think thats the best choice, but you can save the number with NSUserDefaults or something like that, but you will have a problem if the user remove the app and DLs it again.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?