Sending Firebase Cloud Messaging Notifications via REST API
Firebase Cloud Messaging (FCM) provides server-side APIs for sending notifications without using the Firebase Console. To accomplish this, you can utilize the REST API using cURL.
Steps:
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" } }"
Replace
Other Options:
In addition to the REST API, FCM offers Admin SDKs for various platforms. These specifically built-for-purpose SDKs provide an easier interface for sending notifications from within the respective environments. Here's a list of supported platforms: https://firebase.google.com/docs/cloud-messaging/server#client_sdk_api
Historical Note:
An older method using a decommissioned API has been removed from this response. Always refer to the latest documentation provided by Firebase for the most up-to-date information.
The above is the detailed content of How to Send Firebase Cloud Messaging Notifications Using the REST API?. For more information, please follow other related articles on the PHP Chinese website!