自定义推送服务器设置

Custom Push Server Setup

我正在研究构建自定义服务器以向客户端 Web 应用程序发送推送通知(没有 android 或 iOS 手机)。构建此服务的可靠且可扩展的堆栈是什么?最好使用微服务架构。谢谢。

P.S。我已经尝试过 FCM、OneSignal 等第三方服务,但其中大多数不提供自定义域选项。

您可以为此使用 spring-boot 框架,它提供了使用 firebase SDK 或 API 连接 firebase 的简单配置。

  1. 下载 firebase admin SDK:https://console.firebase.google.com/
  2. 创建 spring 引导应用程序:https://start.spring.io/
  3. 使用私钥 JSON 文件通过 SDK 连接 firebase。
  4. 公开 REST 端点以发送 FCM 通知。

对于那些正在寻找当前答案(2021 年 4 月)的人,您不能使用自己的推送服务,因为它与每个浏览器推送紧密耦合 API 实施:

But notice that we can't push notifications from our server directly to the user's browser. Instead, only certain servers that browser development companies (like Google, Mozilla, etc.) specifically choose will be able to push notifications to a given browser.

Link:https://blog.angular-university.io/angular-push-notifications/