fcm icon indicating copy to clipboard operation
fcm copied to clipboard

invalid value error

Open hozdemir opened this issue 5 years ago • 2 comments

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?

hozdemir avatar Jun 12 '20 08:06 hozdemir

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

jeromegamez avatar Jun 17 '20 06:06 jeromegamez

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.

hjbdev avatar Jun 17 '20 09:06 hjbdev