Mahdi Javaheri
Mahdi Javaheri

Reputation: 1250

Open deep link url when click on Fcm notification

I'm using Google's Fcm to send notification to my Android client

I want to open specific screen with Deep Link url eg. example://my.app/products

Here is endpoint to send notification using REST api

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"
     "click_action": "example://my.app/products"
 }
}

This request sends notification to my specified client, but does not open Deep Link, when clicking on push nothing happens

Is there a way to open Deep Link from Fcm Push ?

Upvotes: 16

Views: 13152

Answers (2)

Oleg Yablokov
Oleg Yablokov

Reputation: 835

Note: if you actually want to open a page in your app when the user clicks on a notification, refer to this.

I post it as an answer because I tried to implement opening a page in my app and thought deep links would help but it is probably not the best solution.

Upvotes: 1

Mahdi Javaheri
Mahdi Javaheri

Reputation: 1250

This feature is not mentioned in Fcm documentation but i tried some sort of tests on my own and figured out the solution:

Instead of click_action we need to put link:

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"
     "link": "example://my.app/products"  <<-- Here is the solution
 }
}

Upvotes: 12

Related Questions