I am using firebase to send push notification to my react native app.
I am able to send notification to my device.
I am using https://fcm.googleapis.com/fcm/send to send notification. Below is the body which I am sending to the api.
{
"to": "token",
"notification": {
"body": "body",
"title": "title",
"subtitle": "subtitle"
},
"data": {
"gcm.n.link": "myApp://?screenName=TradeDetail"
}
}
Then I am using Linking to get the url:
Linking.getInitialURL()
.then((initialUrl) => {
console.log("initialUrl: ", initialUrl);
})
.catch((err) => {
console.log("Error getting initial URL:", err);
});
I am getting initial url and able to navigate user to its respective screen.
Problem arises when app is already open, in this case when I click on notification, then nothing happens.
How can I detect url in notification when app is already open and user clicks on it?