kuvardin/firebase-http-api-fcm

There is no license information available for the latest version (dev-main) of this package.

PHP SDK for HTTP Firebase Cloud Messaging Protocol

dev-main 2020-11-16 12:09 UTC

This package is auto-updated.

Last update: 2024-10-16 21:07:27 UTC


README

Usage example

<?php

require 'vendor/autoload.php';

$server_key = 'AAA123456...';
$device_token = 'AAABBBCCC123123...';

$client = new GuzzleHttp\Client();
$api = new Kuvardin\FirebaseHttpApiFcm\Api($client, $server_key);
$target = Kuvardin\FirebaseHttpApiFcm\Target::createWithToken($device_token);

$notification = new Kuvardin\FirebaseHttpApiFcm\Notification(
    'Amazing notification', // title
    'This is my app notification', // body 
    'FLUTTER_NOTIFICATION_CLICK' // click action
);

$response = $api->sendNotification($target, $notification, [
    'key' => 'value', // custom data for app
]);

print_r($response);