Skip to content

Undefined index: message_id when sending a Firebase message to an unregistered device  #42211

Closed
@mishaklomp

Description

@mishaklomp

Symfony version(s) affected: 5.3.3

Description
When sending a push message to a unregistered device. This error pops up.
Screenshot from 2021-07-21 11-26-39
Notice: Undefined index: message_id at /vendor/symfony/firebase-notifier/FirebaseTransport.php:92

I am using a valid device token except it is not registered anymore. This can happen when uninstalling the app it belongs to.
More info on Firebase error codes: https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref.html#error-codes

How to reproduce
Try sending a push message to a "NotRegistered" Firebase device token.

Possible Solution
The FirebaseTransport checks if the Firebase API response by doing:

if ($jsonContents && isset($jsonContents['results']['error'])) {
    throw new TransportException('Unable to post the Firebase message: '.$jsonContents['error'], $response);
}

In my opinion this should be:

 if ($jsonContents && isset($jsonContents['results'][0]['error'])) {
    throw new TransportException('Unable to post the Firebase message: '.$jsonContents['results'][0]['error'], $response);
}

This is a dump of $jsonContents
Screenshot from 2021-07-21 11-09-53

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions