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

如何通过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.

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

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题