Skip to content

How do I handle the notification click event using FCM? #194

Closed
@vkm28

Description

@vkm28

Apart from initial notification handling like
messaging.setBackgroundMessageHandler(function(payload)

how do I add the listener when user clicks on it? I know if I set the "click_action" it will handle it automatically. But I have to do something extra like tracking when user clicks on it and then launch the click_action.
I know with web push, we can do it via
self.addEventListener('notificationclick', function(event) {

but what is equivalent in FCM SDK? or the self.addEventListener('notificationclick', function(event) { will work with FCM SDK also?

also how do I listen to dismiss/close event like with below when using without FCM SDK?
self.addEventListener('notificationclose', function(event) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions