Documentation in FCM focuses heavily on Android/iOS and my lowly webpush
self is struggling with click_action
.
click_action
was a
Click_action works for me but I think it is not documented yet.
I added it in webpush -> notification -> click_action.
Edit : a new option is available in HTTP v1 API.
Confirmed by multiple sources. click_action
is not currently supported for WebPush in HTTP V1 on Firebase Cloud Messaging. Sad!
Use your WebpushNotification.Builder
object and call the putCustomData()
method with click_action
as the key and your click_action
URL as the value.
With the Java Firebase Admin SDK, it looks like this:
wpnb.putCustomData("click_action", "<your_url_here>");
You can include whatever key=>value pairs you want within the data field of your Web Push payload.
Register a notificationclick event listener in your service worker and these data values are available within the event triggered when your notification is clicked. Access your data, then execute your desired click action.