Sending Firebase Cloud Messaging Notifications Without the Firebase Console
Firebase Cloud Messaging provides a versatile platform for sending notifications to Android devices. While the Firebase User Console offers a convenient interface, there may be scenarios where developers prefer to integrate notifications into their own server-side applications.
API-Based Notification Sending
Firebase Cloud Messaging offers a REST API that allows developers to send notifications directly from their servers. This approach provides greater flexibility and customization options.
Step-by-step Instructions:
Request Body: The request body should contain the following data:
"message":
Headers: The request headers should include:
Example Curl Request:
curl -X POST -H "Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA" \ -H "Content-Type: application/json" \ -d '{ "message":{ "notification":{ "title":"FCM Message", "body":"This is an FCM Message" }, "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..." }}' \ https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send
By following these steps, you can successfully send Firebase Cloud Messaging notifications from your own server without using the Firebase User Console.
The above is the detailed content of How to Send Firebase Cloud Messaging Notifications Directly from Your Server?. For more information, please follow other related articles on the PHP Chinese website!