Removing Badge from iOS App Icon

How to remove Appicon Badge, ios10, swift

set badge number = 0.
like UIApplication.shared.applicationIconBadgeNumber = 0

Swift- Remove Push Notification Badge number?

You can "remove" the app badge icon by setting it to 0:

Swift < 3.0

UIApplication.sharedApplication().applicationIconBadgeNumber = 0

Swift 3.0+

UIApplication.shared.applicationIconBadgeNumber = 0

This question shows when you can use it: How to clear push notification badge count in iOS?

how to remove badge notification symbol from app icon in iPhone

Use the below in applicationDidBecomeActive, some any methods in app life cycle..

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

When it is set to zero it should not show any badges.

Remove notification badge icon with specific type

In some case we don't want to set badge icon to ZERO at all. There is method to get app-icon badge numbers.

[UIApplication sharedApplication].applicationIconBadgeNumber =
[UIApplication sharedApplication].applicationIconBadgeNumber - 1;

Once you receive push-alert, you will have some KEY whether its STUFF or STATIC update.

Once user click on push notification from notification tray or on alert. Check for that KEY(Stuff/Static) & using above line change badge number reduce badge number.

I hope this will give you idea.

How to reset the Badge app icon number?

I find that I should not only set the application side like:

UIApplication.sharedApplication().applicationIconBadgeNumber = 0

but I should also set the iCloud side in CKContainer. Therefore, the complete code is like below:

let operation = CKModifyBadgeOperation(badgeValue: 0)
operation.modifyBadgeCompletionBlock = {(error) in
if let error = error{
print("\(error)")
return
}
application.applicationIconBadgeNumber = 0
}
CKContainer.default().add(operation)

How to clear badge counter on click of app icon in iphone?

To clear the badge count whenever the application becomes active use delegate method. You can use UIApplicationDelegate in AppDelegate.

call the [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; in either applicationWillEnterForeground nor applicationDidBecomeActive

- (void)applicationWillEnterForeground:(UIApplication *)application

{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}

or

- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}

Swift

func applicationWillEnterForeground(application: UIApplication) {
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}

or

func applicationDidBecomeActive(application: UIApplication) {
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}

For Swift 3:

UIApplication.shared.applicationIconBadgeNumber = 0

iOS 13 >

func sceneDidBecomeActive(_ scene: UIScene) {
UIApplication.shared.applicationIconBadgeNumber = 0
}

Sample Image



Related Topics



Leave a reply



Submit