1. Go to this page and download the library: Download yamad/laravel-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/ */
yamad / laravel-fcm example snippets
use YamaD\LaravelFcm\Facades\Fcm;
// Send to a device registration token
$response = Fcm::send([
'token' => $deviceToken,
'notification' => [
'title' => 'Hello',
'body' => 'World',
],
]);
echo $response['name']; // projects/{project_id}/messages/{message_id}
// Send to a topic
Fcm::send([
'topic' => 'news',
'notification' => ['title' => 'Breaking news'],
]);
// Dry run (validation only, no delivery)
Fcm::send($message, validateOnly: true);
use YamaD\LaravelFcm\FcmClient;
public function handle(FcmClient $fcm)
{
$fcm->send([...]);
}
bash
php artisan vendor:publish --tag=fcm-config
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.