Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

oo7ml

macrumors 6502
Original poster
Jan 20, 2010
259
0
Hi,

Is it possible to add and increase a badge number on the app icon, without sending a push notification.

For example, my app has a 'like' feature similar to facebook, however i don't want the user to receive a push notification every time another likes their content, but i would like to increase their badge number so that they can see that their has been activity with their content.

Is this possible? Thanks in advance for your help.
 
In iOS 8 (see below for iOS 7) you have the option of what type of notifications you want to register, here is my code below

Code:
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
    
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
    
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

And then I have this in my app delegate

Code:
-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}

So you could just change the settings that you want to register, by passing just the "UIUserNotificationTypeBadge" flag

For iOS 7: you just call

Code:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge];

or whatever type you want to use. Note that this is deprecated in iOS 8
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.