2

私はFCMプッシュ通知機能をPHPに統合しました。今、通知は正常に動作していますが、badgeの番号が機能していません。Firebase Cloud Messaging PHPインテグレーションプッシュ通知を送信

私はbadge = 1を追加しましたが、毎回増分バッジ番号の代わりに1を表示していません。自動インクリメントされたバッジ番号を送信します。

私のPHPファイルのコードを参照してください。

<?php 

    $ch = curl_init("https://fcm.googleapis.com/fcm/send"); 

    //The device token. 
    $token = "DEVICE_TOKEN_HERE"; //token here 

    //Title of the Notification. 
    $title = "Title Notification"; 

    //Body of the Notification. 
    $body = "This is the body show Notification"; 

    //Creating the notification array. 
    $notification = array('title' =>$title, 'text' => $body, 'sound' => 'default', 'badge' => '1'); 

    //This array contains, the token and the notification. The 'to' attribute stores the token. 
    $arrayToSend = array('to' => $token, 'notification' => $notification,'priority'=>'high'); 

    //Generating JSON encoded string form the above array. 
    $json = json_encode($arrayToSend); 
    //Setup headers: 
    $headers = array(); 
    $headers[] = 'Content-Type: application/json'; 
    $headers[] = 'Authorization: key=API_KEY_HERE'; // key here 

    //Setup curl, add headers and post parameters. 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json); 
    curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);  

    //Send the request 
    $response = curl_exec($ch); 

    //Close request 
    curl_close($ch); 
    return $response; 

?> 

私を助けてください!ありがとう。

答えて

0

これは予期された動作です。 iOSは送信したバッジを自動インクリメントしません。送信する前に、サーバー側のバッジの値になるはずのものを決定する必要があります。

また、postを参照してください。

+1

ありがとうございましたALこの記事は既に読んでいますが、その後私はサーバー側からバッジを管理しており、うまくいきます。 :) – mageDev0688

+0

クール。乾杯。 :) –

関連する問題