How to reset/clear the iOS App's badge?

RemoteNotification.applicationIconBadgeNumber is read only, which means I cannot change the badge locally.

I know I gotta use the server to track the badge number. But the situation is, once I received the push notification and activate the app, I upload the data, telling the server “I’ve got your notification”, so that the badge number on the server’s end will reset to 0. But the problem is I cannot change the badge num locally, so the App’s badge number didn’t change.

In order to do that, I gotta let the server send an extra msg after he receives the “I’ve got your notification” msg, telling the App “okay. reset the badge num now”. What an extra work!

Do I have any way to modify/reset/clear the application’s badge number on App’s end in Unity3d?

OneWhoMikes’s answer works for me with any badge number I want, except for 0.
To clear the badge, use applicationIconBadgeNumber = -1.


Thanks Fattie. I’m now using the Obj-C in Xcode to set the badge number. Problem solved. But I’m still curious about how Unity3D’s gonna set that value. And I’m wondering what’s the purpose of make the badge number a read-only in Unity

Something like the following will work from within Unity, no need for Obj-C code:

LocalNotification setCountNotif = new LocalNotification();
setCountNotif.fireDate = System.DateTime.Now;
setCountNotif.applicationIconBadgeNumber = 0;
setCountNotif.hasAction = false;
NotificationServices.ScheduleLocalNotification( setCountNotif );

I’m still struggling with setting the badge through Unity code. If you just want to get rid of the badge whenever the app starts or resumes then add this you your plugins folder.

//  ClearBadgeHelper.m
//  Unity-iPhone
//  Created by Antony Blackett

#import <Foundation/Foundation.h>

@interface ClearBadgeHelper : NSObject
+ (void) clearBadge:(NSNotification *)notification;

@implementation ClearBadgeHelper

+ (void) clearBadge:(NSNotification *)notification
    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;

+ (void)load
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearBadge:) name:UIApplicationDidFinishLaunchingNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearBadge:) name:UIApplicationDidBecomeActiveNotification object:nil];


It’s 2017 now. Unity provides following functions to clear notifications and badge numbers.