exponent-server-sdk-php icon indicating copy to clipboard operation
exponent-server-sdk-php copied to clipboard

Handle more than 100 recipients when sending notifications

Open josephajibodu opened this issue 3 years ago • 2 comments

Error occurs whenever notification is being sent to over 100 recipients.

Unexpected response was received from Expo API. (ExponentPhpSDK\\Exceptions\\UnexpectedResponseException(code: 500): Unexpected response was received from Expo API. at .../vendor/alymosul/exponent-server-sdk-php/lib/Expo.php:221)

Exploring further, here's the actual error message

You can send a maximum of 100 notifications per request (received 7768); divide your requests. {"userId":5,"exception":"[object] (ExponentPhpSDK\\Exceptions\\UnexpectedResponseException(code: 500): You can send a maximum of 100 notifications per request (received 7768); divide your requests. at .../vendor/alymosul/exponent-server-sdk-php/lib/Expo.php:221)

josephajibodu avatar Feb 08 '22 17:02 josephajibodu

As the error message indicates you need to group your recipients into chunks of 100 recipients and send 1 request for each chunk/

Alymosul avatar Feb 08 '22 21:02 Alymosul

// Notify an interest with a notification
$expo->notify([$channelName], $notification);

The notify function receives an array of interests and not arrays of recipients.

Basically, I'm already working on the enhancement that will send the notifications in chunks of less than 100.

I created the issue for tracking purpose. So that I can link my PR to it.

josephajibodu avatar Feb 09 '22 06:02 josephajibodu