Apple push notification not changing icon badge automatically

前端 未结 3 2016
醉梦人生
醉梦人生 2020-12-31 08:42

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

相关标签:
3条回答
  • 2020-12-31 09:10

    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)

    0 讨论(0)
  • 2020-12-31 09:16

    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 :)

    0 讨论(0)
  • 2020-12-31 09:16

    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.

    0 讨论(0)
提交回复
热议问题