Question

For some reason, my app has icon badge of 7 but I have not coded this part of the code and can't seem to get rid of this number. How can I get rid of it or where can I manipulate with this object?

Was it helpful?

Solution

Look for applicationIconBadgeNumber in your code. To reset it to zero, use

[UIApplication sharedApplication].applicationIconBadgeNumber = 0

(you can set this in your App Delegate's application: willFinishLaunchingWithOptions: method)

OTHER TIPS

If you are pushing notifications, you set that in your payload. Look for a badge property in your json payload and remove it. Make sure you also remove that alert type (Badge) from your notification types to register for.

You can, in UIApplication set the enabled remote notification types to only sounds and alerts, omitting the badge type:

- (UIRemoteNotificationType)enabledRemoteNotificationTypes {
    return UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert;
} 

From the docs, it looks like the user has the ability to change this from the Settings app:

The values in the returned bit mask indicate the types of notifications currently enabled for the app. These types are first set when the app calls the registerForRemoteNotificationTypes: method to register itself with Apple Push Notification Service. Thereafter, the user may modify these accepted notification types in the Notifications preference of the Settings app. This method returns those initial or modified values. iOS does not display or play notification types specified in the notification payload that are not one of the enabled types. For example, the app might accept icon-badging as a form of notification, but might reject sounds and alert messages, even if they are specified in the notification payload.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top