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 Get Youtube Video Thumbnail From URL In PHP - Laravel
- Get IP PHP Function Example - ip_info()
- How To Check Valid Integer Values Using PHP Function Example
- How Do Check Whether The Email Address Valid Email Or Not In PHP Example
- Upayments Gateway Integration PHP - Laravel
- Firebase Dynamic Links Shorten URL PHP Function
- IOS Push Notification Send Example
- Zoom API Integration with PHP
- could not encode content to iso-8859-1
- PHP Post Request cURL Example With Authentication