What is push notification ?
Push notification is real time pushing the message to web application in browser or mobile application for real time communication or interaction with the user, Nowadays push notification mostly use for marketing purpose and live broadcasting or others like offer regarding information or other information regarding to their customer from the companies.
What is Firebase notification (FCM) ?
Firebase developed by google for creating mobile application and web application, the Firebase platform is depending on json data store, It NOSQL database programming which is store the data in to json object.
Here below is the working example of a Firebase which is sending the push notification to web application using PHP CURL send request to Firebase cloud server.
IOS Push Notification Send PHP Example
Firebase Cloud Message With PHP CURL
<?php
$notification = [
'notification' => [
'title' => "You notification title put here",
'body' => "You message put here",
'image' => "Image url if you want to show else null",
],
'priority' => "high",
'data' => [
'icon' => 'Put your icon url here.',
'sound' => 'If Yes then 1 or no for 2',
'vibrate' => 'If Yes then 1 or no for 2',
'click_action' => 'NOTIFY_CLICK',
'notification_type' => 'put your notification type (optional)',
'info' => [
'title' => "You notification title put here",
'body' => "You message put here",
'image' => "Image url if you want to show else null",
]
],
'to' => 'device token', // FOR SINGLE TOKEN ONLY
'registration_ids' => ['tokne 1','tokne 2'] // MULTIPLE TOKEN FOR MULTIPLE NOTIFICATION BLUK
];
$headers = [
'Authorization: key=<YOUR-FIREBASE-AUTH-KEY>',
'Content-Type: application/json'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://fcm.googleapis.com/fcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($notification));
$result = curl_exec($ch);
curl_close($ch);
echo 'Notification successfully';
Thank you for read post.
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- How To Remove HTML Tags From The PHP String
- Zoom API Integration with PHP
- Timestamp convert to datetime format
- Get Zipcode/Pincode From Latitude and Longitude PHP and Google Maps API
- Upayments Gateway Integration PHP - Laravel
- IOS Push Notification Send Example
- Create Database In MYSQL Using PHP Script Example
- PHP Post Request cURL Example With Authentication
- Match Function Php 8
- PhonePe Payment Gateway Example PHP