且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用FireBase向iOS发送可执行的通知?

更新时间:2023-09-08 13:41:16

感谢 Malik 为答案。 FCM似乎将Android特定的click_action属性转换为iOS特定的category属性。

我们通过REST API发送Firebase推送通知,可以轻松使用用于邮递员测试。



以下是REST版本:
$ b 发布 https://fcm.googleapis.com/fcm/send



标题:
$ b


  • 授权:key = YOUR_FIREBASE_SERVER_KEY

  • 内容类型:application / json



正文:

  {notification:{
text:YOUR_PUSH_TEXT,
click_action:YOUR_IOS_ACTIONABLE_NOTIFICATION_CATEGORY
},
to:YOUR_PUSH_TOKEN,
data:{
YOUR_CUSTOM_DATA:DATA
}
}


We are currently evaluating Firebase as a future push notification service. Is there a way to send actionable notifications to iOS devices? At the moment we use parse to send pushes, we set the "category" parameter in the payload and the additional actions on the notifications are working. We tried to set this parameter in the firebase console or via the firebase rest api, but the notification actions are not working, it seems the payload is somehow different then iOS expects.

Thanks Malik for the answer. FCM seems to translate the android specific "click_action" property to the iOS specific "category" property.

We send firebase push notifications via their REST API, which can be easily used for testing with postman.

Here is the REST version:

POST https://fcm.googleapis.com/fcm/send

Headers:

  • Authorization: key=YOUR_FIREBASE_SERVER_KEY
  • Content-Type: application/json

Body:

{ "notification": {
    "text": "YOUR_PUSH_TEXT",
    "click_action":"YOUR_IOS_ACTIONABLE_NOTIFICATION_CATEGORY"
  },
  "to" : "YOUR_PUSH_TOKEN",
  "data": {
    "YOUR_CUSTOM_DATA": "DATA"
  }
}