application badge icon not updated when push notification arrives

我们两清 提交于 2019-12-04 11:20:41
Max

Finally this issue is solved. It is true that no one action triggered when app is in background. so didReceiveRemoteNotification method in appDelegate also not triggered when app is in background.

The application badge icon is set by iOS when any new push notification arrives in the device. The payload is same as @rahulPatel says. I do little change in that as BADGE_COUNT is fetched from database, though it is INTEGER but consider as string and string is not taken by iOS thats why my app's badge icon is not updated when notification arrives. Now my code from server side becomes like this :

$badges=(int)$cntmsg;

$body['aps'] = array(
                'alert' => $message,
                'sound' => 'default',
                'badge' => $badges
                //'msg_id'=> $msg_id
            );

so By changing count msg as (int) it solved my issue. Thanks.

Usually in all apps, the unread notification counts are maintained in the server. When the server sends a push notification to a particular device token server sends the badge count along with the payload.

Your server logic needs to keep track of the proper badge count and send it appropriately.

{
    "aps" :  
    {
        "alert" : "Your notification message to show",
        "badge" : BADGE_COUNT ,
        "sound" : "sound.caf"
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!