Open deep link url when click on Fcm notification

拈花ヽ惹草 提交于 2020-12-05 12:46:05

问题


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 ?


回答1:


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
 }
}


来源:https://stackoverflow.com/questions/63203360/open-deep-link-url-when-click-on-fcm-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!