单击Fcm通知时打开深层链接URL

时间:2020-08-01 08:42:28

标签: android firebase-cloud-messaging deep-linking

我正在使用Google的import pandas as pd from datetime import datetime # Input ref_time = datetime(2019,7,12,16,41,20) data = [[6160, 'Upper', '12-7-2019 12:37:51.123572'], [6162, 'Upper', '12-7-2019 12:39:22.355725'], [6175, 'Upper', '12-7-2019 13:21:15.224157'], [6180, 'Upper', '13-7-2019 06:04:29.157111'], [6263, 'Upper', '13-7-2019 07:37:51.123572']] # Convert 2D list to DataFrame object df = pd.DataFrame(data) # Convert timestamp strings in column at index 2 to datetime objects df.iloc[:, 2] = pd.to_datetime(df.iloc[:, 2], format='%d-%m-%Y %H:%M:%S.%f') # Return row with minimum absolute time difference to reference time print(df.loc[[(abs(df.iloc[:, 2]-ref_time)).idxmin()]]) 向我的 Android 客户端发送通知

我想使用Deep Link网址打开特定的屏幕,例如Fcm

这里是使用REST API发送通知的端点

example://my.app/products

此请求会向我指定的客户端发送通知,但在单击“推送”时没有任何反应不会打开深度链接

是否可以通过Fcm Push打开Deep Link?

1 个答案:

答案 0 :(得分:2)

Fcm文档中没有提到此功能,但我自己尝试了一些测试并找出了解决方案:

我们需要放置 link 来代替 click_action

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