简体   繁体   中英

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

I have integrated push notification into iOS app. 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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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