PHP code example of mehdibo / php-fcm

1. Go to this page and download the library: Download mehdibo/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/ */

    

mehdibo / php-fcm example snippets



use Mehdibo\Fcm\Notification\BasicNotification;
use Mehdibo\Fcm\FcmNotifierFactory;
use Mehdibo\Fcm\Receiver\Device;

hboard';

$notifier = FcmNotifierFactory::create($serviceAccountCredentials, $projectId);

$notification = new BasicNotification('This is the title', 'Body goes here');
$receiver = new Device('the token you receive from the user');

$notifier->send($notification, $receiver);


use GuzzleHttp\Client;
use Mehdibo\Fcm\Device\DeviceInfoFetcher;

$client = new Client();
$deviceInfoFetcher = new DeviceInfoFetcher('serverKey', $client);

$deviceInfo = $deviceInfoFetcher->fetchInfo('registrationToken');