laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
495 stars 127 forks source link

setData() array issue #47

Closed dibs439 closed 2 years ago

dibs439 commented 4 years ago

Dear Contributor,

I am facing a problem with related to sending push. the setData() function works well with static values such as

->setData(['data1' => 'value 1', 'data2' => 'value 2'])

However, in my case these information may be variable. When I am doing like this

$data['title'] = "Some title"; $data['body'] = "Some message";

and then passing this

->setData($data);

then notification does not come. How to format it so it will appear in Browser and mobile app client so they can handle the same.

Thanks in advance.

jayhaluska commented 3 years ago

I had the same problem. I fixed it by using strval($myValue) so that the data array only consists of strings. Then the notification appeared again.

I think one can see this as a bug of the library because it could do this or at least throw an error if non-string values are passed in the setData function.

atymic commented 3 years ago

Feel free to PR a fix