Scrathing my head here. What is wrong with this code? The response from Expo is a 404 for some reason. I'm sending stuff to them in the wrong way but can't figure out how I should do it!.
EXPO docs are here: https://docs.expo.io/versions/latest/guides/push-notifications#http2-api
My code:
$client = new Client(); //GuzzleHttp\Client
$url = 'https://exp.host/--/api/v2/push/send';
$data = [
'to' => array('ExponentPushToken[gaXXXXXXXXX_Oi4J1b9OR]'),
'title' => $notification->title,
'body' => $notification->body
];
$headers = [
'Accept' => 'application/json',
'Accept-Encoding' => 'gzip, deflate',
'Content-Type' => 'application/json',
];
$response = $client->post($url, ['form_params' => $data, 'headers' => $headers]);
dd($response);
Getting the following error:
Client error: `POST https://exp.host/--/api/v2/push/send` resulted in a `404 Not Found` response: Not Found
NOTE: Changing 'form_params' to 'multipart' inte the guzzle post gives me a different error from expo:
A 'contents' key is required
And finally, changing 'form_params' to 'query' gives me:
Client error: `POST https://exp.host/--/api/v2/push/send?to%5B0%5D=ExponentPushToken%5XXXXXXXXXX_Oi4J1b9OR%5D&title=asdasd&body=asdasdasd` resulted in a `400 Bad Request` response: {"errors":[{"code":"API_ERROR","message":"child \"to\" fails because [\"to\" is required], \"value\" must be an array."} (truncated...)