Description
When I use '+2' in push notification (Apple), my app badge is correctly increased by 2 (for example, it it was at 0, it passes at 2).
Then, I use
Ti.UI.iPhone.appBadge = 0;
or
Ti.UI.iPhone.appBadge = null;
and the badge correctly disappears.
BUT, if I redo a '+2' push notification, the badge is now at 4!
How you can reproduce this issue:
There is a piece of code (which can be placed alone in app.js since it uses the function *Ti.Network.registerForPushNotifications*):
// Ask for APN registration
Ti.Network.registerForPushNotifications({
types: [
Ti.Network.NOTIFICATION_TYPE_ALERT,
Ti.Network.NOTIFICATION_TYPE_BADGE,
Ti.Network.NOTIFICATION_TYPE_SOUND
],
success: function(e) {
// Send a request to urbanairship to register
},
error: function(e) {
Ti.API.warn('Push notifications disabled: ' + JSON.stringify(e));
},
callback: function () {
// Remove the badge on the main application icon
Ti.UI.iPhone.appBadge = 0;
}
});
Now, the different steps:
. be sure that the current value of the app application icon badge is 0
. with this code, subscribe to APN on an iPhone.
. close your app (or put in in background)
. send a notification with '+2' as badge value and 'hi' has text.
. on your iPhone, when you receive the badge, open the app by accepting the notification
. check the badge icon of your app, it should be '0' (because the code passe its value to '0': Ti.UI.iPhone.appBadge = 0; )
. re-send the same notification
. this time, don't accept the notification
. check the badge icon of your app, it will get '4' as value in stead of '2'
In order for us to progress this issue, please edit your ticket to include a proper [Use-case](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases). Also kindly read the [Submitting Bug Reports](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports) guide before raising tickets. Thank you
Sorry, There is a piece of code:
Now, the different steps: - be sure that the current value of the app application icon badge is 0 - with this code, subscribe to APN on an iPhone. - close your app (or put in in background) - send a notification with '+2' as badge value and 'hi' has text. - on your iPhone, when you receive the badge, open the app by accepting the notification - check the badge icon of your app, it should be '0' (because the code passe its value to '0': Ti.UI.iPhone.appBadge = 0; ) - re-send the same notification - this time, don't accept the notification - check the badge icon of your app, it will get '4' as value in stead of '2'
This is good, Romain, but the script should run without modification when added to a blank app.js. Hence, where is the window created? You should include this, so that the core devs can replicate the behavior in the shortest time. Also, are you able to modify/improve the actual ticket, rather than post comments?
Ticket updated, sorry for the inconvenience...
No problem, Romain - thanks for bringing this to our attention. I've moved it to the appropriate project now.
I dont think this is a Titanium issue. You will need to make a device registration call to reset the server-side counter when using the autobadge feature, as stated in this thread at Urban Airship: https://support.urbanairship.com/customer/portal/questions/369931-setbadgenumber-doesn-t-update-value-server-side.
Closing due to inactivity. If this issue still exists, please raise a new ticket.