Closed play4uman closed 1 year ago
Yes, you can put whatever additional field you like into the data
object of a push notification and extract it from the FCMNotification
data property. So in your case you could send the notification like this:
https://fcm.googleapis.com/fcm/send
Content-Type: application/json
Authorization: key={SERVER_KEY}
{
"to" : "{Firebase client token}",
"collapse_key" : "type_a",
"notification" : {
"body" : "Body of Your Notification",
"title": "Title of Your Notification"
},
"data" : {
"link": "example://my.app/products" <<-- Here is the solution
}
}
Extract the link from FCMNotification
like this:
private void HandleNotification(FCMNotification notification)
{
var link = notification.Data["link"];
// navigate to link's destination
}
@TobiasBuchholz Thank you that works perfectly!
Suppose that we want to implement a functionality like Facebook Messenger where clicking on the notification for a received chat message would open the app on the exact chat page that the notification was received, i.e. "deep linking" when opening the notifications. Is this possible with the current implementation?
According to this SO reply it's possible by setting the "Link" property in the "Notification" object using the firebase REST SDK but I was unable to test it since I'm using the Firebase Admin SDK which doesn't have a "Link" property under the "Notification" object.