如何使用 FireBase 向 iOS 发送可操作的通知? [英] How to send actionable notifications to iOS with FireBase?

查看:21
本文介绍了如何使用 FireBase 向 iOS 发送可操作的通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在评估 Firebase 作为未来的推送通知服务.有没有办法向 iOS 设备发送可操作的通知?在我们使用 parse 发送推送的那一刻,我们在有效负载中设置了类别"参数,并且通知的附加操作正在运行.我们尝试在 firebase 控制台或通过 firebase rest api 设置此参数,但通知操作不起作用,看来有效负载与 iOS 预期的有些不同.

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.

推荐答案

感谢 Malik 的回答.FCM 似乎将 android 特定的click_action"属性转换为 iOS 特定的category"属性.

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

我们通过他们的 REST API 发送 firebase 推送通知,可以很容易地使用 postman 进行测试.

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

这是 REST 版本:

Here is the REST version:

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

标题:

  • 授权:key=YOUR_FIREBASE_SERVER_KEY
  • 内容类型:应用程序/json

身体:

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

这篇关于如何使用 FireBase 向 iOS 发送可操作的通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆