gfonseca/phpfcm

There is no license information available for the latest version (v0.3.0) of this package.

PHP API for Firebase cloud message

Installs: 38

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/gfonseca/phpfcm

v0.3.0 2018-08-10 13:42 UTC

This package is not auto-updated.

Last update: 2025-10-08 21:24:06 UTC


README

PHP API for Firebase cloud message

<?php
include __DIR__."/../vendor/autoload.php";

define("CONCURRENCY", 50);
define("ACCESS_TOKEN", "google_access_token");

$client_list; // <=list of clients loaded from database

// You also can use PHPFCM\FCMClient::makeMessagePool()
$pack = PHPFCM\FCMClient::makeNotificationPool(
    function($client){
        return array(
            "to" => $client->token,
            "message_options" => array(
                "dry_run" => false
            ),
            "notification" => array(
                "title" => "Hello {$client->name}!",
                "body" => "have a look at our offers, Mr. {$client->last_name}! "
            )
        );
    },
    $client_list
);

$fcm = new PHPFCM\FCMClient(
    ACCESS_TOKEN,
    CONCURRENCY
);

$response = $fcm->sendPack($pack);

foreach($response as $r) {
    echo $r->getMessageID();
    echo "\n";
}