PHP code example of erickskrauch / fcm
1. Go to this page and download the library: Download erickskrauch/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/ */
erickskrauch / fcm example snippets
use ErickSkrauch\Fcm\Client;
use ErickSkrauch\Fcm\Message\Message;
use ErickSkrauch\Fcm\Message\Notification;
use ErickSkrauch\Fcm\Recipient\Device;
$client = new Client('SERVICE ACCOUNT OAUTH TOKEN', 'project-x146w');
$notification = new Notification(, 'testing body');
$notification->setTitle('Wow, something happened...');
$notification->setBody('It just works!');
$message = new Message();
$message->setNotification($notification);
$message->setCollapseKey('collapse.key');
$recipient = new Device('your-device-token'); // or new ErickSkrauch\Fcm\Recipient\Topic('topic');
$result = $client->send($message, $recipient);