推送通知徽章自动增加 [英] Push-Notification Badge auto increment

查看:19
本文介绍了推送通知徽章自动增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为我的应用程序实施推送服务,我一直在考虑应用程序的徽章.我的应用程序是一个邮件应用程序(有点),我想通过推送通知用户添加到收件箱的新消息,我希望徽章 = 收件箱中的新消息数.

I've been implementing the push service to my application, and I've been thinking about the application's badge. My app is a mail app (sorta) and I want to notify the user via push for new messages added to the inbox, I want the badge = number of new messages in the inbox.

我想在服务器端(提供商)检查新消息并将号码作为徽章发送.

I thought of doing it server sided (provider) checking for new messages and sending the number as the badge.

问题是:有没有办法自动增加应用程序的徽章,而不必计算服务器端的徽章值,然后将其作为推送负载的一部分发送到 APSN?

The question is: Is there a way to auto-increment the application's badge, without having to calculate the badge value server sided and afterwards sending it as a part of the push payload to the APSN?

也许有一种方法可以在 JSON 徽章字段中发送一些诸如++"之类的变量.任何黑客?还是我需要使用服务器端的计数系统??

Maybe there's a way to send in JSON badge field some variable like "++" or something like that. Any hack for that? Or do I need to go with the counting system server-sided??

推荐答案

不,你必须在服务器端跟踪这个.如果您不为徽章添加任何值,它将被完全删除.

Nope, you'll have to track this on the server side. If you don't include any value for badge, it will get removed completely.

当然,这只是在用户收到通知并且应用未运行/他们选择不启动它的情况下.如果用户启动应用或已经运行应用,您可以随心所欲地进行增量操作.

Of course though this is only if the user receives the notification and the app isn't running/they choose not to launch it. If the user launches the app or already had it running you can do whatever you want in regards to incrementing.

2014 年 3 月更新:查看评论以了解可能的更新.我已经好几年没有做推送了,所以我自己也无法验证.

UPDATE March 2014: See comments for a possible update. I haven't done pushes in several years so haven't been able to verify this myself.

这篇关于推送通知徽章自动增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆