Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4248] Issues with 'Ti.UI.iPhone.appBadge' ans push notifications as '+2'

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-07-26T23:43:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
LabelsappBadge, notification, push
ReporterRomain
AssigneeIngo Muschenetz
Created2011-05-24T08:12:15.000+0000
Updated2017-07-26T23:43:19.000+0000

Description

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'

Comments

  1. Paul Dowsett 2011-05-30

    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
  2. Romain 2011-05-30

    Sorry, There is a piece of code:
       // 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'
  3. Paul Dowsett 2011-05-30

    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?
  4. Romain 2011-05-30

    Ticket updated, sorry for the inconvenience...
  5. Paul Dowsett 2011-05-30

    No problem, Romain - thanks for bringing this to our attention. I've moved it to the appropriate project now.
  6. Jonas Funk Johannessen 2012-08-29

    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.
  7. Lee Morris 2017-07-26

    Closing due to inactivity. If this issue still exists, please raise a new ticket.

JSON Source