问题描述
问题:
- 假设我收到 3 条通知.
- 它在我的应用图标上显示徽章计数 3.
- 我打开应用或点击通知,它会清除徽章(到目前为止一切都很好)
- 现在,当我收到新通知时,我的应用上会显示徽章计数图标是 4 而不是 1
- 这意味着在 Urbanairship 端没有重置徽章数量li>
到目前为止我的代码:
-(void)resetBadgeNotifications:(UIApplication *)application using:(NSDictionary *)notificationInfo{
if( notificationInfo != nil ){
[[NSNotificationCenter defaultCenter] postNotificationName:@"newNotification" object:notificationInfo];
}
application.applicationIconBadgeNumber=1;
application.applicationIconBadgeNumber=0;
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[application cancelAllLocalNotifications];
[[UAPush shared] setBadgeNumber:1];//set to 1
[[UAPush shared] resetBadge];//zero badge
}
我从以下三个地方调用这个方法:
I am calling this method from the following three places:
didFinishLaunchingWithOptions
didRegisterForRemoteNotificationsWithDeviceToken
applicationDidBecomeActive
在我函数的最后一行,我清楚地重置了 UrbanAirship 上的徽章.但它似乎不起作用.如果我遗漏了什么,有人可以纠正我吗?
In the last line of my function, I am clearly resetting the badge on UrbanAirship. But it seems to be not working. Can anyone please correct me if I am missing something?
推荐答案
我最初的答案是针对 APNS 提供的基本推送通知.我不知道 UrbanAirship 有一种机制来跟踪每个令牌的徽章编号.阅读他们的文档,您可能忘记调用:
My original answer was for the basic push notifications offered by APNS.I wasn't aware that UrbanAirship have a mechanism to track the badge number for each token.Reading their documentation, it's possible that you forgot to call:
[[UAPush shared] setAutobadgeEnabled:YES]
如果您的应用程序使用 Urban Airship 的自动徽章功能,请启用客户端自动徽章跟踪应用程序:didFinishLaunchingWithOptions:更改徽章之前价值:
[[UAPush 共享] setAutobadgeEnabled:YES];[[UAPush 分享]resetBadge];//零徽章
[[UAPush shared] setAutobadgeEnabled:YES]; [[UAPush shared] resetBadge];//zero badge
这篇关于重置城市飞艇徽章数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!