How to Send Push notification using FCM(Firebase Cloud Messaging) using php

Firebase Cloud Messaging(FCM) is a google cloud messaging service it is used for sending notification and messages in cross-platform for android, web application and ios application, which is available at no cost.

If you want to use this service in your application please just follow below simple steps and then you can send notification using google FCM(Firebase Cloud Messaging) service.

MySQL Database Table for store user device ids and store data in table

Step 1 : Create database table in which you need to store users device token.

Step 2 : After create database table you need to store users information in table with FCM device id.

Here we will show how to store users information in database using php.


PHP script code for sending notification using FCM.
Step 1 : Get all database users FCM device id, on which you want to send notifications.

Step 2 : Create data array with device ids for sending push notification

Step 3 : Declare and define Fcm class in fcm.php file, which is included previously