2

PHP에 FCM 푸시 알림 기능을 통합했습니다. 이제 알림이 제대로 작동하지만 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

쿨. 건배. :) –

관련 문제