exponent-server-sdk-php
exponent-server-sdk-php copied to clipboard
an notify exception occurs on certain tokens
An notify exception occurs on certain tokens. Error message is "\Exceptions\UnexpectedResponseException(code: 500): Unexpected response was received from Expo API".
The causative token ends in "_lD]". If you register multiple tokens including this one and send push notifications, an error will occur. But Push notifications will not fail if only this token is used. Is it possible that "_lD]" has been changed to some kind of control character?
souce code
// EXPOセットアップ
$expo = Expo::normalSetup();
foreach ($expoPushTokens as $expoPushToken) {
// EXPO登録
Log::debug('subscribe expo', ['channel' => $channel, 'expo_push_token' => $expoPushToken]);
try {
$expo->subscribe($channel, $expoPushToken);
} catch (\Exception $ex) {
Log::error('subscribe exception', [$ex]);
try {
// EXPO解除
$expo->unsubscribe($channel);
} catch (\Exception $ex) {
Log::error('subscribe->unsubscribe exception', [$ex]);
return;
}
return;
}
}
$notification = [
'title' => $title,
'body' => $body,
'data' => json_encode($data),
'_displayInForeground' => true,
];
try {
// プッシュ通知
$expo->notify([$channel], $notification);
} catch (\Exception $ex) {
// ↓Location of error Log::error('notify exception', [$ex]); }
try {
// EXPO解除
$expo->unsubscribe($channel);
} catch (\Exception $ex) {
Log::error('unsubscribe exception', [$ex]);
return;
}