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

invalid value error #37

Closed hozdemir closed 2 years ago

hozdemir commented 4 years ago

I'm trying to send data as follows in sendFcm method;

return FcmMessage::create() ->setData(['type' => 'xxx', 'id' => 21465]) ->setNotification(\NotificationChannels\Fcm\Resources\Notification::create() ->setTitle('a title') ->setBody('a body') ) ->setAndroid(AndroidConfig::create() ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics')) ->setNotification(AndroidNotification::create()->setColor('#0A0A0A')) ) ->setApns(ApnsConfig::create()->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios')));

but causing an error;

ERROR: Invalid value at 'message.data[1].value' (TYPE_STRING), 21465 {"exception":"[object] (NotificationChannels\\Fcm\\Exceptions\\CouldNotSendNotification(code: 0): Invalid value at 'message.data[1].value'

how can it be solved?

jeromegamez commented 4 years ago

Replace 21465 with '21465' - the data payload of an FCM message allows strings only.

hjbdev commented 4 years ago

Yep this is correct ^ Meant to comment when I found the a fix last night. It must be a string.

I was trying to send an array down, the data object has to be key->val strings only.