N
Novu15mo ago
dmgarland

Adding a 'link' option to web push via FCM

I'm using Firebase (FCM) provider to send push notifications to web browsers via Novu. I'm trying to set the link option so that clicking the notification takes the user back to the website. I can get push notifications, title, body and images are working: but I can't seem to set the link property as per the interface here: https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.webpushconfig Looking at the docs / code, I expect that I should be able to send a payload like
curl --location --request POST 'https://url.to.our.selfhosted.novu' \
--header 'Authorization: ApiKey KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "workflow-name",
"to": {
...
},
"overrides": {
"fcm": {
"webPush": {
"fcmOptions": {
"link": "https://www.novu.co"
}
}
}
}
}'
curl --location --request POST 'https://url.to.our.selfhosted.novu' \
--header 'Authorization: ApiKey KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "workflow-name",
"to": {
...
},
"overrides": {
"fcm": {
"webPush": {
"fcmOptions": {
"link": "https://www.novu.co"
}
}
}
}
}'
I can see that other webPush settings I'm setting such as imageUrl work - but I can't seem to get the link value to come through. I've tried fcmOptions and fcm_options but neither seems to work. Does anyone have any experience getting this value across to the service worker?
4 Replies
Pawan Jain
Pawan Jain15mo ago
Hi @dmgarland If above code is not working, try with data fields
overrides: {
fcm: {
imageUrl: "YOUR_IMAGE_URL",
data: {
click_action: "YOUR_LINK"
}
},
},
overrides: {
fcm: {
imageUrl: "YOUR_IMAGE_URL",
data: {
click_action: "YOUR_LINK"
}
},
},
dmgarland
dmgarlandOP15mo ago
Cracked it, posting for posterity: You cannot use absolute URLs as the link parameter, but only relative URLs. This is very confusing as the Firebase docs stipulate using HTTPS and imply (so it seems to me) that therefore the whole URL is required ! The following worked for me
curl --location --request POST 'https://url.to.our.selfhosted.novu' \
--header 'Authorization: ApiKey KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "workflow-name",
"to": {
...
},
"overrides": {
"fcm": {
"webPush": {
"fcm_options": {
"link": "/foo"
}
}
}
}
}'
curl --location --request POST 'https://url.to.our.selfhosted.novu' \
--header 'Authorization: ApiKey KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "workflow-name",
"to": {
...
},
"overrides": {
"fcm": {
"webPush": {
"fcm_options": {
"link": "/foo"
}
}
}
}
}'
Linear
Linear15mo ago
Pawan Jain
Pawan Jain15mo ago
Thanks for sharing @dmgarland We will update the info in docs
Want results from more Discord servers?
Add your server