【问题标题】:How to send iOS push notifications from my server using Firebase?如何使用 Firebase 从我的服务器发送 iOS 推送通知?
【发布时间】:2021-03-08 08:32:24
【问题描述】:

我正在编写一个 Java 后端,我需要将推送通知发送到 iOS 设备。 请注意,我想知道如何配置我的后端以将推送负载发送到 Firebase,然后它应该将其发送到 iOS 设备。由于某些限制,我不想直接使用 Apple http/2 套接字。您能否指出我正确的 Firebase 文档?

【问题讨论】:

  • 有。你试过搜索 Apple 开发者文档吗?
  • @Gavin,Apple 文档为什么要讨论如何使用 Firebase 来做到这一点?
  • 我认为该评论是因为您已将 apple-push-notifications 作为标签包含在您的问题中。您是否查看过 Cloud Messaging 的入门指南?
  • @Jay,是的,我也在下面更新了我的答案。

标签: java ios firebase apple-push-notifications javapns


【解决方案1】:

得到了答案 - 我们必须使用 Firebase 公开的 REST API,如下所示 -

端点:https://fcm.googleapis.com/fcm/send

主体:

{  
  "notification" : {
     "title" : "You received simple notification!",
     "badge" : 1,   
     "sound" : "notification.wav",
     "body" : "This push was sent by FCM API",
     "custom" : {"key1":"value1","key2":"value2"},
     "priority":"high"
  },
  "content_available": false,
  "to":"FIREBASE_DEVICE_TOKEN"
}

不要忘记添加标题如下 -

Content-Type:application/json
Authorization:key=FIREBASE_SERVER_KEY

不要忘记在您的应用中集成 iOS/Android SDK 以获取令牌并发送推送通知!

【讨论】:

    猜你喜欢
    • 2019-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    • 2014-07-11
    • 1970-01-01
    相关资源
    最近更新 更多