Notification badges

Hi,

I’m using the following code to test notifications,

[lua]local options = {
alert = “”,
badge = 1,
}

for i=1, 3 do
options.alert = ‘message ‘…i
local notification = system.scheduleNotification( 10*i, options )
end[/lua]

As you can see I’m creating 3 notifications (10 seconds apart). These appear as expected however the badge number only goes to ’1?… why doesn’t it display ’3?.

(using build 2012.797) [import]uid: 117657 topic_id: 26286 reply_id: 326286[/import]

local options = {  
 alert = “”,  
 badge = 1,  
}  
   
for i=1, 3 do  
 options.alert = ‘message ‘..i  
 options.badge = i  
 local notification = system.scheduleNotification( 10\*i, options )  
end  

[import]uid: 22829 topic_id: 26286 reply_id: 106604[/import]

The badge count isn’t handled by iOS but by your app. You pass the number you wish to show in the corner of the icon in the options table. To keep track of how many push notifications has been sent to a user, you could create a database that holds the device token and a badge count, before sending a new push retrieve the badge count, add one, update the database and then send the push away. And when the user launches the app you reset the push count in the database to 0 [import]uid: 14018 topic_id: 26286 reply_id: 106620[/import]

Thanks Hoan, Mitaten,

Very confusing because that’s completely different to how it’s defined in the docs.

The badge parameter is a numerical amount that the current badge number will be incremented. So in the example above, if the app’s icon had a 3 in the badge, the red badge would then display a 5 after the notification is sent. Pass a negative number to decrement, and pass 0 to not change the badge count at all.

I’ll add a comment on those pages to let others know.

thanks again
Greg [import]uid: 117657 topic_id: 26286 reply_id: 106643[/import]