laravel-fcm-notification icon indicating copy to clipboard operation
laravel-fcm-notification copied to clipboard

Associating Listener Result to Notification Sent

Open tangjh opened this issue 6 years ago • 1 comments

Any idea how I can associate the listener result back to the notification sent? Basically after sending multiple notifications, I want to find out how many success and failure for each of them.

tangjh avatar Jun 20 '18 04:06 tangjh

Unfortunately, you can't identify the invalid/failing device token by looking at the event data.

Your app has to remember which device tokens the messages were sent to, and in what order they were provided.

Then you must compare the index (position) of the failing message with the index of the device tokens you provided. For example, let's say you send a message to tokens A, B and C. FCM responds with an array of successes and/or errors. If the first item in the result array is a failure, it means that the first token you provided -- token A -- failed.

Here's an article that explains it: https://www.sentinelstand.com/article/device-group-management-with-firebase-cloud-messaging (Specifically the section "The Legacy FCM HTTP protocol")

nicoqh avatar Jul 02 '18 19:07 nicoqh