Replies: 3 comments 6 replies
-
Just to be sure that we are talking about the same: this limitation is in the SDK to prevent errors or unexpected results after sending a message to the Firebase FCM API (see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message.FIELDS.data, where it's stated that What you could do is to $data = [
'title' => $title,
'body' => $body,
"ledColor" => json_encode([0, 0, 255, 0]),
'actions' => json_encode([
'title' => "test",
'callback' => 'test',
'foreground' => "true"
])
]; |
Beta Was this translation helpful? Give feedback.
-
I just checked the documentation again (I previously looked at it on my mobile phone) and am happy to be able to tell you that you can apply the LED/light settings now already. Now more explicitly referring to https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?hl=en#androidnotification, you should be able to configure the light settings like this: $androidConfig = [
'notification' => [
'title' => 'Android specific notification title',
'body' => 'Android specific notification body',
// If set to true, use the Android framework's default LED light settings for the notification.
// Default values are specified in config.xml. If default_light_settings is set to true and
// light_settings is also set, the user-specified light_settings is used instead of the
// default value.
'default_light_settings' => false,
// see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#lightsettings
'light_settings' => [
// see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Color.SCHEMA_REPRESENTATION
'color' => [
'red' => 0,
'green' => 0,
'blue' => 255,
'alpha' => 0
],
'light_on_duration' => '3.5s',
'light_off_duration' => '3.5s',
]
],
];
$message = CloudMessage::withTarget('token', $deviceToken)
->withAndroidConfig($androidConfig);
$messaging->send($message); |
Beta Was this translation helpful? Give feedback.
-
As for the actions - I just tested sending the actions example from the Cordova docs you shared after disabling the "one dimensional strings" check, and the Firebase API did not accept the message, as expected. After researching the topic a little further, I stumbled upon https://stackoverflow.com/q/45006551/284325 which confirms that actions are not supported by the FCM Rest API and has a more detailed in-depth description of what I proposed earlier (JSON encoding on your backend, and decoding in the client) in its comments. |
Beta Was this translation helpful? Give feedback.
-
error
How do I include an array of values for "actions" and "ledcolor" as it will only accept a one dimension array?
Beta Was this translation helpful? Give feedback.
All reactions