0

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?

KENdi
  • 7,576
  • 2
  • 16
  • 31
Artiic
  • 1
  • Possible duplicate of [multicast id in firebase cloud messaging service](https://stackoverflow.com/questions/44586336/multicast-id-in-firebase-cloud-messaging-service) – AL. Aug 24 '17 at 14:54

2 Answers2

0

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

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.