我从新的 Google 通知服务开始,Firebase Cloud Messaging
.
感谢这段代码https://github.com/firebase/quickstart-android/tree/master/messaging https://github.com/firebase/quickstart-android/tree/master/messaging我能够从我的设备发送通知Firebase 用户控制台到我的 Android 设备。
有没有任何 API 或方法可以在不使用 Firebase 控制台的情况下发送通知?我的意思是,例如,PHP API 或类似的东西,可以直接从我自己的服务器创建通知。
Firebase Cloud Messaging 有一个服务器端 API,您可以调用它来发送消息。看https://firebase.google.com/docs/cloud-messaging/server https://firebase.google.com/docs/cloud-messaging/server.
发送消息就像使用curl
调用 HTTP 端点。看https://firebase.google.com/docs/cloud-messaging/server#implementing-http-connection-server-protocol https://firebase.google.com/docs/cloud-messaging/server#implementing-http-connection-server-protocol
curl -X POST --header "Authorization: key=<API_ACCESS_KEY>" \
--Header "Content-Type: application/json" \
https://fcm.googleapis.com/fcm/send \
-d "{\"to\":\"<YOUR_DEVICE_ID_TOKEN>\",\"notification\":{\"title\":\"Hello\",\"body\":\"Yellow\"}}"
您可以在任何环境中使用所有这些 REST API,但列出的许多平台都有专用的所谓管理 SDKhere https://firebase.google.com/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)