Apple push notification not changing icon badge automatically

前端 未结 3 2018
醉梦人生
醉梦人生 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: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.

提交回复
热议问题