2017 © Pedro Peláez
 

library fcm

A PHP library to send push notification through Firebase Cloud Messaging

image

kerox/fcm

A PHP library to send push notification through Firebase Cloud Messaging

  • Sunday, October 30, 2016
  • by ker0x
  • Repository
  • 3 Watchers
  • 3 Stars
  • 332 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 111 % Grown

The README.md

Tests Coverage PHP Version Download Packagist License, (*1)

Fcm

A PHP library to send push notification with Firebase Cloud Messaging, (*2)

[!NOTE] Version 3.x of this library is a full rewrite using PSR-18 HTTP Client interface, which means that no HTTP Client, like Guzzle or httplug, are provided within. If you already have one in your project, the package will automatically discover it and use it. Otherwise You will need to require one separately., (*3)

[!WARNING] Version 3.2 introduce a BC break. The signature of the __construct() method of the Kerox\Fcm\Model\Message class has changed, with the $notification parameter becoming the third argument and being optional., (*4)

Installation

You can install Fcm using Composer:, (*5)

composer require kerox/fcm

You will then need to: * run composer install to get these dependencies added to your vendor directory * add the autoloader to your application with this line: require('vendor/autoload.php');, (*6)

Basic usage

use Kerox\Fcm\Fcm;
use Kerox\Fcm\Model\Message;
use Kerox\Fcm\Model\Notification\Notification;
use Kerox\Fcm\Model\Target;

$fcm = new Fcm('<oauth_token>', '<project_id>');

// Create the message
$message = new Message(
    target: new Token('TopicA'),
    data: [
        'story_id' => 'story_12345',
    ],
    notification: new Notification(
        title: 'Hello World',
        body: 'My awesome Hello World!'
    ),
)

// Send the message and get the response
$response = $fcm->send()->message($message);

Documentation

The documentation is available here, (*7)

Testing

To live test the package, you must first generate an OAuth token. Go to https://developers.google.com/oauthplayground/ and select Firebase Cloud Messaging API v1 from the list of APIs. Then select https://www.googleapis.com/auth/firebase.messaging and generate the OAuth token. Finally, define an environment variable named FCM_OAUTH_TOKEN and assign it the value of the access token., (*8)

The Versions

30/10 2016

dev-master

9999999-dev https://github.com/ker0x/fcm

A PHP library to send push notification through Firebase Cloud Messaging

  Sources   Download

MIT

The Requires

 

The Development Requires

notification push fcm firebase cloud messaging

30/10 2016

1.0.1

1.0.1.0 https://github.com/ker0x/fcm

A PHP library to send push notification through Firebase Cloud Messaging

  Sources   Download

MIT

The Requires

 

The Development Requires

notification push fcm firebase cloud messaging

30/10 2016

dev-develop

dev-develop https://github.com/ker0x/fcm

A PHP library to send push notification through Firebase Cloud Messaging

  Sources   Download

MIT

The Requires

 

The Development Requires

notification push fcm firebase cloud messaging

30/10 2016

1.0.0

1.0.0.0 https://github.com/ker0x/fcm

A PHP library to send push notification through Firebase Cloud Messaging

  Sources   Download

MIT

The Requires

 

The Development Requires

notification push fcm firebase cloud messaging