简体   繁体   English

安装应用后,如何隐藏Apple Push Notification徽章计数?

[英]How to hide the apple push notification badge count, as soon as app installed?

I have integrated push notification into iOS app. 我已将推送通知集成到iOS应用中。 My problem is once I install the app, and reinstall it in another time, even before I login through the app my app icon shows the badge count. 我的问题是,一旦我安装了该应用程序,然后再次安装它,甚至在我通过该应用程序登录之前,我的应用程序图标都会显示徽章计数。 I dont want to show it if the user has logged out. 如果用户已注销,我不想显示它。 So when user click on the logout I set the badge count as 0. But when I install it again, even before I log into it my app shows the notification badge count as a different number. 因此,当用户单击注销时,我将徽章计数设置为0。但是,当我再次安装它时,即使在我登录之前,我的应用程序也会将通知徽章计数显示为另一个数字。

How can I avoide this? 我该如何避免呢? Please help me. 请帮我。 Thanks 谢谢

You need to add more logic to your badge updates. 您需要为徽章更新添加更多逻辑。 In the app delegate, when the app is launched and / or you receive a notification you should check the user login status and update the badge number. 在应用程序委托中,当应用程序启动和/或收到通知时,您应检查用户登录状态并更新徽章编号。 If the user is not logged in then you can always simply set to zero. 如果用户未登录,则可以始终将其设置为零。

set badge 0 inside logout button action 将徽章0设置为注销按钮操作

-(void)logout{
  [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  //.....
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM