• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Van Zeng · Mar 30, 2013 at 12:15 PM · iosnotificationbadges

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

RemoteNotification.applicationIconBadgeNumber is read only, w$$anonymous$$ch 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?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Van Zeng · Mar 30, 2013 at 02:41 PM 0
Share
avatar image Fattie · Mar 30, 2013 at 03:50 PM 0
Share
avatar image Fattie · Mar 31, 2013 at 12:24 PM 0
Share

5 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Van Zeng · Mar 31, 2013 at 12:22 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
4

Answer by privman · Jul 25, 2013 at 03:51 PM

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

Source: http://forum.unity3d.com/threads/127016-Using-the-new-notification-system?p=921134&viewfull=1#post921134

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ensomniac · May 15, 2014 at 09:01 PM 0
Share
avatar image Nolex · Sep 14, 2016 at 09:56 PM 0
Share
avatar image
1

Answer by HereIAmItsMe · May 01, 2013 at 10:58 PM

Somet$$anonymous$$ng like the following will work from wit$$anonymous$$n 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 );
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Antony-Blackett · May 11, 2017 at 01:51 AM

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 t$$anonymous$$s you your plugins folder.

 //
 //  ClearBadgeHelper.m
 //  Unity-iPhone
 //
 //  Created by Antony Blackett
 
 #import <Foundation/Foundation.h>
 
 @interface ClearBadgeHelper : NSObject
 + (void) clearBadge:(NSNotification *)notification;
 @end
 
 @implementation ClearBadgeHelper
 
 + (void) clearBadge:(NSNotification *)notification
 {
     [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
 }
 
 + (void)load
 {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearBadge:) name:UIApplicationDidFinishLaunc$$anonymous$$ngNotification object:nil];
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearBadge:) name:UIApplicationDidBecomeActiveNotification object:nil];
 }
 
 @end


Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by abcjjy · Dec 05, 2017 at 02:16 PM

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

 NotificationServices.ClearLocalNotifications()
 NotificationServices.ClearRemoteNotifications()
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to know when my game is in background? 1 Answer

How to properly remove a scheduled ios notification 1 Answer

iOS Notifications Resume Game 0 Answers

MissingMethodException - Parse and iOS 64-bit 1 Answer

iOS LocalNotifications Not Changable 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges