drkug66408
2015-05-18 14:26
浏览 106

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

图片转代码服务由CSDN问答提供 功能建议

现在我正在通过swift处理IOS应用程序项目。 我每次需要增加徽章编号时 服务器推送通知到设备。 现在它总是1个徽章没有增加。

这是我的有效负载。

  // 创建有效负载主体
 $ body ['aps'] =数组(
'警报'=> $消息,
'声音'=>'默认',
'徽章'=> 1 
  ); 
 //将有效负载编码为JSON 
 $ payload = json_encode($ body); 
 $ messageId = $ randomNotiId; 
   
 
 

谢谢!< / p>

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题