0
votes

I send notifications in my server with PHP to FCM with this function:

function sendGCM($ch1,$ch2, $message) {

    $url = 'https://fcm.googleapis.com/fcm/send';

    $fields = array (
            'to' => $ch1
            ,
            'data' => array (
                    "message" => $message
            )
    );
    $fields = json_encode ( $fields );

    $headers = array (
            'Authorization: key=' . $appID,
            'Content-Type: application/json'
    );

    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, $url );
    curl_setopt ( $ch, CURLOPT_POST, true );
    curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields );

    $result = curl_exec ( $ch );

    curl_close ( $ch );
    echo $result;
}

The response is this {"message_id":9191006033691432523}. In the documentation, https://firebase.google.com/docs/cloud-messaging/http-server-ref multicast_id, success, failure parameters are required in the response but.

What is the reason for this?

2

2 Answers

0
votes

You are sending message to specified by $ch1 topic, if I understand ok, instead to multiple devices by their registrationIds.

So you are reciving Topic message HTTP response body (JSON) (table 6) instead of Downstream HTTP messages

0
votes

From what I've understood from FCM and your question is that you'll get the multicast_id in the response only when you are sending notifications to unique devices and not in case of topic notifications.