簡體   English   中英

Firebase 推送通知添加動作按鈕

[英]Firebase push notification adding action buttons

我在服務器端發送推送通知,我正在使用這個 http 協議( https://firebase.google.com/docs/cloud-messaging/http-server-ref ),我想在問題https中添加這樣的操作按鈕//github.com/FirebaseExtended/flutterfire/issues/1484 這是我的請求正文

{
  "registration_ids": [
    "secret"
  ],
  "notification": {
    "title": "New Article",
    "body": "Article content",
    "sound": "default",
    "actions": [
      {
        "action": "like-button",
        "title": "Like",
        "url": "https://example.com"
      },
      {
        "action": "read-more-button",
        "title": "Read more",
        "url": "https://example.com"
      }
    ],
    "click_action": "read-more-button"
  },
  "data": {
    "id": "some uuid",
  }
}

我試過了,但什么也沒有出現。 我該如何解決這個問題? 先感謝您。

FCM 目前不支持此功能。 解決方案是通過 FCM 發送數據消息並創建您自己的通知。

  1. 使用您自己的鍵值對發送數據消息:
  "data": {
    "key": "value",
    "key2": "value2"
  }
  1. 接收消息,使用擴展FirebaseMessagingService的服務。
  2. 覆蓋onMessageReceived回調以根據您的數據消息創建通知。

https://firebase.google.com/docs/cloud-messaging/android/receive

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM