I\'m trying FCM for the first time, so just using their sample code. In fact I\'m even sending their sample messages. The following code, which is straight from the document
I had "
in my strings in my json, I changed it to '
and it fixed the problem!
$response = $client->post(
'https://fcm.googleapis.com/v1/projects/xxx/messages:send',[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $token['access_token'],
],
GuzzleHttp\RequestOptions::JSON => [
"message" => [
"token" => "dflhjldkjhflksfshklsf",
"notification" => [
"title" => "FCM Message",
"body" => "This is an FCM notification message!"
]
]
]
]);
to:
$response = $client->post(
'https://fcm.googleapis.com/v1/projects/xxx/messages:send',[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $token['access_token'],
],
GuzzleHttp\RequestOptions::JSON => [
'message' => [
'token' => 'dflhjldkjhflksfshklsf',
'notification' => [
'title' => 'FCM Message',
'body' => 'This is an FCM notification message!'
]
]
]
]);
Hope it helps!