Cordova Firebase推送通知不正确的徽章计数器

时间:2018-07-06 14:46:02

标签: php cordova firebase push-notification

在我的设备上收到通知时,它会在应用程序图标上添加徽章计数器,这很好,但是如果我仅发送一个推送通知,即使1个通过,它始终显示为2。

如果我要发送3个推送通知,它也将停留在2。

public function pushnotification($message, $token)
{
    $fcmUrl = 'https://fcm.googleapis.com/fcm/send';

    $notification = [   'title' => 'Application',
                           'body'   => $message,
                    ];

    $fcmNotification =  [   'to'            => $token,
                            'notification'  => $notification
                        ];

    $headers =  [   'Authorization  : key=AAAAAE7zWXs:APA91bGCG8Czq7gkR4ygEQP_C7FbwJzC_4eozjyeAlLNd7HsIvTUJ45EzAhVM1YUORII7qmI1LRgRGY-gTcg3nRw4-KdnIPOY8VMAwzc8WhJHHbdDwNDxj3bG7iGCXwg7o5tzUf4_iuA',
                    'Content-Type   : application/json'
                ];

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $fcmUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));

    $result = curl_exec($ch);

    curl_close($ch);        
}

0 个答案:

没有答案