推送通知徽章没有出现?
我正在使用 Urban Airship 向我的应用程序发送推送通知
,例如:
{"aps": {"badge": 2, "alert": "Part 2 of the August Issue is ready to download!", "sound": "default"}, "device_tokens": ["X"]}
警报将完美显示,但是无论我将“badge”设置为什么,应用程序图标都不会带有标记:#...
我的有效负载是否不正确或者是否有额外的内容我应该添加到我的应用程序中来处理徽章和警报的代码?谢谢!
编辑: 我正在注册这样的推送通知:
// Register for notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeNewsstandContentAvailability | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
I'm using Urban Airship to send push notifications to my app
eg:
{"aps": {"badge": 2, "alert": "Part 2 of the August Issue is ready to download!", "sound": "default"}, "device_tokens": ["X"]}
The alert will display perfectly, however the app icon is never badged regardless of what I set "badge":# to...
Is my payload incorrect or is there extra code I'm supposed to add to my app to handle badges as well as alerts? Thanks!
EDIT:
I'm registering for push notifications like this:
// Register for notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeNewsstandContentAvailability | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在运行类似的问题。检查了几分钟后。我注意到我的服务器端代码有问题。我发现徽章值必须隐式设置为整数才能获得所需的结果。希望对阅读本文的人有所帮助。
I was running with a similar problem. After a few minutes of checking around. I notice that there was a problem with my server side code. I found out that badge value has to be implicitly set as an integer to get the desired result. Hope that helps anyone reading this.
在 appdelegate .m 文件中设置以下代码。
set the following code in the appdelegate .m file..
在iOS 5中有一个设置->通知。仔细检查徽章应用程序图标是否已打开。
我假设您测试时该应用程序不在前台?如果它位于前台,那么您必须手动处理徽章。
In iOS 5 there is a Settings -> Notifications. Double check that the Badge App Icon is turned on.
I assume that the app is not in the foreground when you were testing? It if is in the foreground then you have to handle badging manually.