Firebase click_action 不工作
Firebase click_action not working
我遇到了 FCM 问题,Firebase 团队记录了这一点:
click_action: Indicates the action associated with a user click on the notification. When this is set, an activity with a matching intent filter is launched when user clicks the notification.
我知道它已经被讨论过,但根据我的理解,根据我从文档中了解到的情况,这应该可以从 firebase 控制台实现。它没有说它用于数据消息,它清楚地表明它是一个用于通知消息的字段,据我所知,这些是 Firebase 控制台发送的。
谁能澄清一下。
谢谢!!
控制台目前似乎不支持click_action。在 Firebase 控制台中编写通知时,您要么必须使用 API 来触发通知,要么尝试通过高级部分中的自定义数据字段传递 click_action 参数(到目前为止我还没有尝试过) ,但可能有效)。
click_action 目前无法通过 Firebase 控制台使用。
您说控制台发送通知消息是正确的,但是它不允许您设置通知消息的 click_action 字段。要使用 click_action,您必须使用 REST API 发送通知消息,其中所有通知消息字段都可用。
请注意,通过控制台添加的自定义数据在通知消息随附的数据负载中变为 key/value 对。示例结构:
{
"to": <topic>,
"notification": {
<notification payload>
},
"data": {
<data payload, console custom data key/value pairs go here>
}
}
因此 click_action 是通知负载的一部分,但此时您必须使用 REST API 才能使用它。我知道这还不清楚,我会研究可能的文档更新以使其更清楚。
您可以使用以下 Rest 服务片段从 RestClient (Postman) 发送推送消息
Method : POST
URL: https://fcm.googleapis.com/fcm/send
Header:
Authorization : key=<FCM SERVER LEGACY KEY>
Content-Type: application/json
Body:
{
"notification": {
"title": "Firebase notification",
"message": "I am firebase notification. you can customise me. enjoy",
"click_action": "OPEN_ACTIVITY",
"sound":"default",
}
,
"to": "<Your device FCM Token - Getting it from the FirebaseInstanceIdService>"
}
在您的清单文件中 - 包含 Intent 过滤器以匹配 Click_action 值:
例如:
<activity
android:name=".ui.NotificationActivity"
>
<intent-filter>
<action android:name="OPEN_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
我遇到了 FCM 问题,Firebase 团队记录了这一点:
click_action: Indicates the action associated with a user click on the notification. When this is set, an activity with a matching intent filter is launched when user clicks the notification.
我知道它已经被讨论过,但根据我的理解,根据我从文档中了解到的情况,这应该可以从 firebase 控制台实现。它没有说它用于数据消息,它清楚地表明它是一个用于通知消息的字段,据我所知,这些是 Firebase 控制台发送的。
谁能澄清一下。 谢谢!!
控制台目前似乎不支持click_action。在 Firebase 控制台中编写通知时,您要么必须使用 API 来触发通知,要么尝试通过高级部分中的自定义数据字段传递 click_action 参数(到目前为止我还没有尝试过) ,但可能有效)。
click_action 目前无法通过 Firebase 控制台使用。
您说控制台发送通知消息是正确的,但是它不允许您设置通知消息的 click_action 字段。要使用 click_action,您必须使用 REST API 发送通知消息,其中所有通知消息字段都可用。
请注意,通过控制台添加的自定义数据在通知消息随附的数据负载中变为 key/value 对。示例结构:
{
"to": <topic>,
"notification": {
<notification payload>
},
"data": {
<data payload, console custom data key/value pairs go here>
}
}
因此 click_action 是通知负载的一部分,但此时您必须使用 REST API 才能使用它。我知道这还不清楚,我会研究可能的文档更新以使其更清楚。
您可以使用以下 Rest 服务片段从 RestClient (Postman) 发送推送消息
Method : POST
URL: https://fcm.googleapis.com/fcm/send
Header:
Authorization : key=<FCM SERVER LEGACY KEY>
Content-Type: application/json
Body:
{
"notification": {
"title": "Firebase notification",
"message": "I am firebase notification. you can customise me. enjoy",
"click_action": "OPEN_ACTIVITY",
"sound":"default",
}
,
"to": "<Your device FCM Token - Getting it from the FirebaseInstanceIdService>"
}
在您的清单文件中 - 包含 Intent 过滤器以匹配 Click_action 值: 例如:
<activity
android:name=".ui.NotificationActivity"
>
<intent-filter>
<action android:name="OPEN_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>