gpt4 book ai didi

push-notification - 重置 urbanairship 徽章计数

转载 作者:行者123 更新时间:2023-12-02 03:40:57 24 4
gpt4 key购买 nike

问题:

  • 假设我收到 3 条通知。
  • 它在我的应用程序图标上显示徽章计数 3。
  • 我打开应用程序或点击通知,它清除了徽章(到目前为止一切都很好)
  • 现在,当我收到新通知时,我的应用程序上会显示徽章计数图标是 4 而不是 1
  • 这意味着徽章计数没有在 Urbanairship 端重置

到目前为止我的代码:

-(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
}

我从以下三个地方调用这个方法:

didFinishLaunchingWithOptions

didRegisterForRemoteNotificationsWithDeviceToken

applicationDidBecomeActive

在我的函数的最后一行,我清楚地重置了 UrbanAirship 上的徽章。但它似乎不起作用。如果我遗漏了什么,有人可以纠正我吗?

最佳答案

我最初的回答是针对 APNS 提供的基本推送通知。我不知道 UrbanAirship 有一种机制来跟踪每个 token 的徽章编号。阅读他们的文档,您可能忘记调用:

[[UAPush shared] setAutobadgeEnabled:YES]

If your application uses Urban Airship’s autobadge feature, enable client-side autobadge tracking in application:didFinishLaunchingWithOptions: before changing the badge value:

[[UAPush shared] setAutobadgeEnabled:YES]; [[UAPush shared] resetBadge];//zero badge

关于push-notification - 重置 urbanairship 徽章计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20073212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com