Reputation: 936
Documentation in FCM focuses heavily on Android/iOS and my lowly webpush
self is struggling with click_action
.
click_action
was a key which could be used in older APIs and appears to be no longer available for webpush
.
The only specific reference to this is in this blog post: https://firebase.googleblog.com/2017/11/whats-new-with-fcm-customizing-messages.html which again focuses on iOS and Android.
I am looking for clarity that click_action
is indeed now unsupported for webpush
messages.
Upvotes: 1
Views: 6885
Reputation: 121
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>");
Upvotes: 2
Reputation: 914
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.
Upvotes: 2
Reputation: 5941
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.
Upvotes: 0
Reputation: 936
Confirmed by multiple sources. click_action
is not currently supported for WebPush in HTTP V1 on Firebase Cloud Messaging. Sad!
Upvotes: -2