PHP code example of maximerenou / php-fcm
1. Go to this page and download the library: Download maximerenou/php-fcm library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maximerenou / php-fcm example snippets
// Instantiate the client with the project api_token and sender_id.
$client = new \Fcm\FcmClient($apiToken, $senderId);
// Instantiate the push notification request object.
$notification = new \Fcm\Push\Notification();
// Enhance the notification object with our custom options.
$notification
->addRecipient($deviceId)
->setTitle('Hello from php-fcm!')
->setBody('Notification body')
->setSound('custom_sound')
->addData('key', 'value');
// Send the notification to the Firebase servers for further handling.
$client->send($notification);
bash
composer