How to open app by clicking on push notification?

I am using capacitor for push notification . when I receive a notification i want to open app by clicking on notification but that is not working how I can do it?

// Method called when tapping on a notification
PushNotifications.addListener('pushNotificationActionPerformed',
  (notification) => {

    console.log('App opened',notification)
    router.push('/tabs/tab1');
  }
);

The default behaviour of push notifications is to open the app when you tap them, so unless you did something “weird” it should just work. Hard to know with the little detail you provided.

1 Like

by default it is not opening the app…

You have to change the backend payload for that…

can you please provide me an example?

{
“to” : “fjS2HYDJvVk:APA91bHbGoGOFKbk6XVhq6nVxU1LxHk48pCUe7P3aZRcMMA4ToXWib4R_eLRoQZeJJpZoklDvv3Yl23wnH4r0-VSX_16O7SD_I9t_vgdoZNCAS1LA0KE9oRz0-59h9JB60WgTwc2enfS”,
“collapse_key” : “type_a”,
“notification”:{
},
“data”:{
“title”:“Hey”,
“body”:“Its done”,
“param1”:“value1”,
“param2”:“value2”
},
“priority”:“high”,
“content_available”: true
}

Not sure if this will work though