Reputation: 228
Im using UILocalNotificaion to send push notifications to the user but im facing a problem that the little 1 number above the app icon wont come off. Does anyone know how can i fix it?
this is the code of the notification:
let fire = Date(timeIntervalSinceNow: 10)
localNotification.fireDate = fire
localNotification.alertBody = textsArray[Int(randomNum)]
localNotification.applicationIconBadgeNumber = 1
localNotification.repeatInterval = .weekOfYear
localNotification.soundName = UILocalNotificationDefaultSoundName
APP.scheduleLocalNotification(localNotification)
Upvotes: 0
Views: 30
Reputation: 3081
On your AppDelegate, go into ApplicationDidBecomeActive method and add
application.applicationIconBadgeNumber = 0
That way, every time the user opens the app (if its a new open or it was open from the background, this will fire and reset the badge
Upvotes: 1
Reputation: 535411
the little 1 number above the app icon wont come off. Does anyone know how can i fix it?
You don't show any code that makes the number 1 "come off". But you are the one who put the badge on. It won't magically "come off" by itself. If you want to remove it, you must remove it.
You can readily do this at any time by setting the shared application's applicationIconBadgeNumber
to zero.
Upvotes: 0