Hi all, I have a little problem here, I want to modify the app badge on my iphone titanium based application. I was able to do it when the app is focused (foreground), but when I do it in backgound ... it won't do it I do send in the json of the push notification the alert message, the sound and the badge number... it ignores the badge number the push notification work fine...except badge
my push notification structure:
{"aps":{"badge":"3","alert":"help","sound":"sound.caf"}}My event :
Titanium.Network.registerForPushNotifications({ types: [ Titanium.Network.NOTIFICATION_TYPE_BADGE, Titanium.Network.NOTIFICATION_TYPE_ALERT, Titanium.Network.NOTIFICATION_TYPE_SOUND ], success:function(e) { }, error:function(e) { // label.text = "Error during registration: "+e.error; }, callback:function(e) { } Titanium.UI.iPhone.appBadge = e.data.badge; Ti.Media.vibrate(); } });
3 Answers
Solved! the badge needs to be numeric,
//php code $body['aps']['badge'] = (int)$badge; $body['aps']['alert'] = $message; $body['aps']['sound'] = $sound; $payload = json_encode($body);so.. unless you don't do in your server part of the code (i am using php)
it won't work
When in background the callback isn't called at all, you need to figure out the values from the server implementation
Look at your app badge code. It is using the e object to access the badge number, but the appBadge set is NOT in a callback. You need to set the appBadge inside one of the callbacks in order to use the e.data.badge property. Otherwise e doesn't even exist.
Ok, Im putting this in a separate answer as to not confuse it with previous entries. Can you try deleting the app from your device and reinstalling. I read a Jira ticket where this happened in a dev environment and the issue was resolved by removing the app from device.
Your Answer
Think you can help? Login to answer this question!