Check Part 1 : How to Connect Firebase to Android Studio

Most web apps use webservices in PHP Firebase to send personalised messages to users for various purposes

  1. To send reminders of any activity
  2. To promote an event or a sale
  3. To notify the user of an update
Android Firebase Notification
Firebase Notification

To send a Firebase Cloud message from PHP, you need the following data:

  1. Firebase Server key
    • GO to Firebase Console ->Click on your APP -> Overview – Gear Icon ->Project Settings -> Cloud Messaging -> Server Key
  2. Firebase token key of the device where you need to send notification
    • eg: cuhI71WMYMo:APA91bGhCbSSU4K……………

Create a Notification.php file as below

Set the api Server key of firebase. The url is the legacy firebase url where we need to send out data payload of the notification.


This is the data payload which contains title, body of the notification. The activity is an optional field which is sent to open a custom activity instead of the default launcher activity in your Android App.


Finally we use CURL which is a php library for network HTTP request. We use this to send our data to Firebase server to be sent to the user device.


You can use the above code alongwith a mysql query to run it inside a loop to send custom notification to multiple android and ios users.


Leave a Comment

Your email address will not be published. Required fields are marked *