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

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

问题描述

我们目前正在评估Firebase作为未来的推送通知服务。
有没有办法将可操作的通知发送到iOS设备?
目前我们使用parse来发送推送,我们在有效载荷中设置category参数,通知中的附加操作正在工作。
我们试图在firebase控制台或通过firebase rest api设置这个参数,但通知操作不起作用,看起来有效载荷在某种程度上与iOS预期的不同。

解决方案

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

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



以下是REST版本:
$ b 发布 < a href =https://fcm.googleapis.com/fcm/send =nofollow noreferrer> 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"
  }
}

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

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