Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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, 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?

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

Additionally, even I send the extra msg from my server, telling the App to reset the badge, the only way to do that is to send a push notification, setting the badge's number in the payload. That sounds ridiculous! Because that means I gotta use 2 push notifications, one for the real deal, and the other for clearing the badge?? That's impossible, so it gotta be some other way, even without extra plugins.

avatar image Fattie · Mar 30, 2013 at 03:50 PM 0
Share

could you use LOCAL notifications ?????????? to do this ?

I know that at Prime31 that is the "Etc Two" package.

avatar image Fattie · Mar 31, 2013 at 12:24 PM 0
Share

awesome you could do that at the XCode level. good one

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

Thanks for adding this comment! The -1 is the correct answer and works perfectly.

avatar image Nolex · Sep 14, 2016 at 09:56 PM 0
Share

Thanks! Works fine with -1.

avatar image
1

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

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 );
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 this 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:UIApplicationDidFinishLaunchingNotification 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.

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

Scheduled notification not cleared 2 Answers

iOS local notifications never appear 1 Answer

Create Notification Service Extension using PostProcessBuild Script for Xcode 10 0 Answers

Detect if iOS Build is Development, Ad-Hoc, or AppStore at Runtime 1 Answer

System.NotSupportedException: SafeArray element type Int64 is not supported. Unity Mobile Notifications 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