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.

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

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python