I have seen the mail app in my iPhone (4S, iOS 5.1) automatically updates the badge count if new mail arrives, even when app is not running. So it is possible to achieve thi
I also had this exact same problem. The badge icon was not quoted. After many hours of trying to tweak the JSON (after verifying app on phone showed badges, sounds, alerts) - the problem was I had added UIRemoteNotificationTypeNewsstandContentAvailability as one of the alert types my app was registering for. (I went crazy, just picking everything)
So, when UIRemoteNotificationTypeNewsstandContentAvailability
is also in the mix, it seems to override the function of allowing aps/badge numbers to update an app icon. (Must be looking to update newsstand info)
The issue is now fixed. The provider server was sending the badge number in quotation marks (as JSON String, i.e. "9"). Strange that APNs/iOS does not recognize it as integer. Now the quotes are removed and it works :)
I had a similar problem, solved it by forcing integer in the badge number (using PHP with data coming from MySQL db):
$body['aps'] = array(
'alert' => array(
'action-loc-key'=> utf8_encode($r['button_action']),
'body' => utf8_encode($r['message']),
'launch-image' => ''
),
'badge' => (int)$r['badge_number'],
'sound' => 'default'
);
Ps.: take a look at the utf8_encode
command to avoid a json_encode
error I faced earlier too.