单击Fcm通知时打开深层链接URL [英] Open deep link url when click on Fcm notification
问题描述
我正在使用Google的 Fcm
向我的 Android 客户端
我想使用Deep Link网址打开特定的屏幕,例如 example://my.app/products
这是使用REST API发送通知的端点
https://fcm.googleapis.com/fcm/send内容类型:application/json授权:key = {SERVER_KEY}{至":"{Firebase客户令牌}","collapse_key":"type_a",通知":{身体":您的通知的主体",标题":您的通知标题"" click_action" ;:" example://my.app/products"}}
此请求会向我指定的客户端发送通知,但在单击推送"时没有任何反应不会打开深度链接
是否可以通过Fcm Push打开Deep Link?
Fcm文档中没有提到此功能,但是我自己尝试了一些测试并找出了解决方案:>
我们需要放置 link 而不是 click_action :
https://fcm.googleapis.com/fcm/send内容类型:application/json授权:key = {SERVER_KEY}{至":"{Firebase客户令牌}","collapse_key":"type_a",通知":{身体":您的通知的主体",标题":您的通知标题"链接":"example://my.app/products"<<-这是解决方案}}
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 ?
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
}
}
这篇关于单击Fcm通知时打开深层链接URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!