fcm icon indicating copy to clipboard operation
fcm copied to clipboard

setData() array issue

Open dibs439 opened this issue 4 years ago • 2 comments

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.

dibs439 avatar Aug 06 '20 15:08 dibs439

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.

jayhaluska avatar Jun 30 '21 17:06 jayhaluska

Feel free to PR a fix

atymic avatar Jul 01 '21 01:07 atymic