2

I'm using urban air ship component for titanium appcelerator.

iOS sdk ios6.1 Titanium SDK 3.1.1GA

When i send a notification by urban air ship, i receive the message and the notification ..that's ok ! and the application badge is set to the number i've sent ..it's cool !

But when i start my application the badge never come back to 0... i always have 1 notification set for the badge.

I've tried to clear all notifications with :

Titanium.UI.iPhone.setAppBadge(null);
Titanium.UI.iPhone.setAppBadge("0");
Titanium.UI.iPhone.setAppBadge("-1");

Titanium.UI.iPhone.badge = "0";
Titanium.UI.iPhone.badge = "-1";
Titanium.UI.iPhone.badge = null;

Ti.App.iOS.cancelAllLocalNotifications();

Nothing can clear the badge... it's always set to 1.

Anyone can help ? Is there a property that i have to set 0 or to null ??

Thx !

Zuhn
  • 79
  • 9
  • My first guess is that the code be called thus: `Titanium.UI.iPhone.setAppBadge(0);` since it want's a number not a string. Also `Ti.App.iOS.cancelAllLocalNotifications();` will only work for local not for push notifications. – rckoenes Oct 23 '13 at 13:57
  • gonna try with number... maybe my mistake with the doc : http://developer.appcelerator.com/apidoc/mobile/1.8.0.1/Titanium.UI.iPhone.setAppBadge-method.html – Zuhn Oct 23 '13 at 14:31
  • 1
    The documentation you linked to is out of date, it's for 1.8.* try: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.iPhone – rckoenes Oct 23 '13 at 14:36
  • Tried with number, but same result..the badge come again and again with 1. I've sent a new test notification (urbanairship) with a badge value to 20.. when i receive the notification the badge change for the good value 20 I open the application.. and close it.. and the badge come back to 1 .. it's amazing !! – Zuhn Oct 23 '13 at 14:54
  • Check if you are using `Titanium.UI.iPhone.setAppBadge()` in some other place, probably some background process. Also try removing application from device. – daniula Oct 24 '13 at 01:27

2 Answers2

1

you can reset the notification badge by placing this line where you want in your project

Titanium.UI.iPhone.appBadge=0;
Dario Rusignuolo
  • 2,090
  • 6
  • 38
  • 68
-4

Have you tried this ?

-(void)applicationDidBecomeActive:(UIApplication *)application
{

 [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
 [[UIApplication sharedApplication] cancelAllLocalNotifications];


 Titanium.UI.iPhone.setAppBadge(0);
 Ti.App.iOS.cancelAllLocalNotifications();

 }
Nithin M Keloth
  • 1,595
  • 1
  • 20
  • 37