Skip to content

an notify exception occurs on certain tokens #84

@tomohiro-katano

Description

@tomohiro-katano

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;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions