iOS Applications can have a number badge on their home screen icon, this is accomplished with the UIApplication class’s setApplicationIconBadgeNumber method. The IBMMobilePush SDK now sends a NSNotification with the name “InboxCountUpdate” whenever the number of inbox messages changes or when the number of unread messages changes. This can be used to keep the application badge count up to date. The sample project includes examples on how to use this notification to update the application badge count:


-(void)inboxUpdate {
    int unreadCount = [[MCEInboxDatabase sharedInstance] unreadMessageCount];
    dispatch_async(dispatch_get_main_queue(), ^{
        [UIApplication.sharedApplication setApplicationIconBadgeNumber: unreadCount];

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self inboxUpdate];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inboxUpdate) name: InboxCountUpdate object:nil];


@objc func inboxUpdate() {
        DispatchQueue.main.async {
            UIApplication.shared.applicationIconBadgeNumber = Int(MCEInboxDatabase.shared.unreadMessageCount())
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool
        NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.inboxUpdate), name:
            MCENotificationName.InboxCountUpdate.rawValue, object: nil)

Join The Discussion

Your email address will not be published. Required fields are marked *