FCM Notification: Unable to Send link Parameter via PHP SDK Overrides
Hi @Pawan Jain ,
I'm using the PHP SDK to trigger an FCM notification, and I'm facing an issue with sending custom parameters. Here’s the approach I’m currently using:
$overrides = new \novu\Models\Components\Overrides(
null, // steps
[ // providers
'fcm' => [
'webPush' => [
'fcmOptions' => [
'link' => '/my-tasks/6',
],
],
],
]
);
$triggerEventRequestDto = new \novu\Models\Components\TriggerEventRequestDto(
workflowId: $workflow,
payload:$notificationPayload ,
to: $subscribers,
overrides: $overrides
);
While the notification is being sent with the title and body, the link parameter isn’t appearing in the received payload.
When I attempt to send it as a data message instead, like this:
$overrides = new \novu\Models\Components\Overrides(
null, // steps
[ // providers
'fcm' => [
"type" =>"data",
'data' => [
'link' => '/my-tasks/6',
],
],
]
);
I receive the following error in the activity feed:
Unexpected provider error 15:01:52 "Sending message failed due to "data must be a non-null object""Am I missing something in how the PHP SDK handles overrides? Specifically, does the SDK fully support passing custom data fields this way? Or is there a different approach required when working with FCM overrides? Thanks in advance for your help!
4 Replies
@Jish
Could you please check with
overrides => [
'fcm' => []
]
in place of
'overrides' => [
'providers' => [
'fcm' => []
]
]
@Pawan Jain Thanks for the response. This is what I tried. The providers in the array is just a comment. The overrides component's (\novu\Models\Components\Overrides) first parameter is steps, and the second one is for providers. So I commented that in the code for future reference.
Jish, could you please try mine suggestion and remove steps?
That approach didn’t work for some reason, but I was able to get it working by overriding the steps instead of the providers.
$overrides = new \novu\Models\Components\Overrides(
[
'push-step' => [
'providers' => [
'fcm' => [
"data" => [
"url" => "/task-management/my-tasks"
],
'android' => [
'notification' => [
'sound' => 'sound_bell', // Android custom sound
]
],
'apns' => [
'payload' => [
'aps' => [
'sound' => 'notification_bell.caf', // iOS custom sound
]
]
]
]
]
]
]
);