PHP code example of redjanym / php-firebase-cloud-messaging
1. Go to this page and download the library: Download redjanym/php-firebase-cloud-messaging 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/ */
redjanym / php-firebase-cloud-messaging example snippets
use RedjanYm\FCM\Client;
use RedjanYm\FCM\Notification;
use RedjanYm\FCM\Recipient\Device;
$serviceAccountPath = '/path/to/service-account.json';
$client = new Client($serviceAccountPath);
$recipient = new Device('your-device-token');
$notification = new Notification($recipient, 'Title', 'Body', ['key' => 'value']);
$response = $client->send($notification);
use RedjanYm\FCM\Client;
use RedjanYm\FCM\Notification;
use RedjanYm\FCM\Recipient\Topic;
$serviceAccountPath = '/path/to/service-account.json';
$client = new Client($serviceAccountPath);
$recipient = new Topic('news');
$notification = new Notification($recipient, 'Title', 'Body', ['key' => 'value']);
$response = $client->send($notification);