Badge Number But No Push Notification

Discussion in 'iOS Programming' started by oo7ml, Oct 31, 2014.

  1. oo7ml macrumors 6502

    Jan 20, 2010

    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.
  2. Ann P macrumors 68020

    Jun 29, 2009
    Badge Number But No Push Notification

    Oops ignore sorry. Didn't see this was in programming, lol.
  3. waterskier2007 macrumors 68000


    Jun 19, 2007
    Novi, MI
    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

    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

    -(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

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge];
    or whatever type you want to use. Note that this is deprecated in iOS 8
  4. leventozler macrumors 6502

    Feb 18, 2009
    Send a push notification with only the badge key.
  5. oo7ml thread starter macrumors 6502

    Jan 20, 2010

Share This Page