cordova-plugin-firebase-messaging icon indicating copy to clipboard operation
cordova-plugin-firebase-messaging copied to clipboard

Add support for click_action

Open chemerisuk opened this issue 6 years ago • 8 comments

click_action Optional, string

The action associated with a user click on the notification.

  • iOS: Corresponds to category in the APNs payload.
  • Android: If specified, an activity with a matching intent filter is launched when a user clicks on the notification.

https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types?language=objc https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SupportingNotificationsinYourApp.html#//apple_ref/doc/uid/TP40008194-CH4-SW26

chemerisuk avatar Apr 18 '19 19:04 chemerisuk

You could steal what they have in the cordova-plugin-firebase

tmk1991 avatar May 22 '19 21:05 tmk1991

Any updates of this?

andrsdev avatar Jun 24 '19 17:06 andrsdev

I am also looking for the same functionality. Any updates on this?

anilwarbhe avatar Dec 31 '19 08:12 anilwarbhe

@chemerisuk Any updates on this?

jayant1993 avatar Feb 19 '20 10:02 jayant1993

I am not sure if i understood you right but using the onBackgroundMessage should be what you are looking for. This is called, when the user clicks on the notification and the app opens.

DokuMe avatar May 21 '20 17:05 DokuMe

I am not sure if i understood you right but using the onBackgroundMessage should be what you are looking for. This is called, when the user clicks on the notification and the app opens.

But it does not fire any callback event when click on the head up notification on android

trung-pham avatar Oct 07 '20 17:10 trung-pham

I am not sure if i understood you right but using the onBackgroundMessage should be what you are looking for. This is called, when the user clicks on the notification and the app opens.

But it does not fire any callback event when click on the head up notification on android

It should. It does fire onBackgroundMessage callback in my code. If nothing happens after the notification being clicked. One possible reason is you have click_action in your fcm notification payload but doesn't have corresponding intent filter setup in your manifest.xml

asxasdfghjkl avatar Oct 13 '20 09:10 asxasdfghjkl

For those that haven't used Intent filters before (like me) It was a little confusing trying to get it to work but after some trial and error I managed to get it working with this code.

Inside config.xml within the android platform tags:

<!-- notification redirect on notification tap --> <config-file target="AndroidManifest.xml" parent="/manifest/application/activity"> <intent-filter> <action android:name="FCM_PLUGIN_ACTIVITY" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </config-file>

This is what my cloud function looks like:

Screen Shot 2021-07-30 at 10 58 50 AM

luisVargasGu avatar Jul 30 '21 14:07 luisVargasGu