如何使用 fcm 和 j2ee 向 android 发送通知

how to send a notification to android using fcm and j2ee

我想构建一个应用程序以从 j2ee web 应用程序向我们的客户端应用程序发送通知 android。

我找到了很多示例,但使用 google 云消息传递而不是使用 FCM。

我想要一个使用 java 中的简单函数来执行此操作的示例。

此功能允许从我的服务器向安装在 android 设备中的移动应用程序发送通知。

是的,你可以通过FCM来实现。我没有使用过 j2ee,但可以给你一些指导来完成这项工作。

  1. 配置您的应用程序以接收来自 Firebase 的通知 安慰。有很多可用的教程,而且非常简单。
  2. 使用 POST 请求将通知从您的服务器发送到设备。这是 json 部分。

......

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIhhjGu76G...P0Gzu7B5aAnoYUd
{   
    "data": {
      "title": "notification_title",
      "body": "notification_body"
    },
    "to" : "jh578_gsh....jhHGFJ76FH"
}