2017-25 © Pedro Peláez
 

library larafcm

Laravel FCM Package

image

cimons/larafcm

Laravel FCM Package

  • Wednesday, July 11, 2018
  • by cimons
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel-FCM

Introduction

Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with Firebase Cloud Messaging (FCM)., (*1)

It currently only supports HTTP protocol for :, (*2)

  • sending a downstream message to one device

Note: The XMPP protocol is not currently supported., (*3)

Installation

To get the latest version of Laravel-FCM on your project, require it from "composer":, (*4)

$ composer require cimons/larafcm:dev-master

Or you can add it directly in your composer.json file:, (*5)

{
    "require": {
           "cimons/larafcm": "dev-master"
    }
}

Laravel

Register the provider directly in your app configuration file config/app.php config/app.php:, (*6)

'providers' => [
    // ...

    Cimons\LaraFcm\LaraFcmServiceProvider::class,
]

Add the facade aliases in the same file:, (*7)

'aliases' => [
    ...
    'FCM'             => Cimons\LaraFcm\Facades\FCM::class,
]

Copy the config file fcm.php manually from the directory /vendor/cimons/larafcm/config to the directory /config (you may need to create this directory)., (*8)

Package Configuration

In your .env file, add the server key and the secret key for the Firebase Cloud Messaging:, (*9)

FCM_SERVER_KEY=my_secret_server_key
FCM_SENDER_ID=my_secret_sender_id

Downstream Messages

A downstream message is a notification message, a data message, or both, that you send to a target device or to multiple target devices using its registration_Ids., (*10)

The following use statements are required for the examples below:, (*11)

use Cimons\LaraFcm\Message\NotificationBuilder;
use Cimons\LaraFcm\Facades\FCM;

Sending a Downstream Message to a Device

```php, (*12)

$notificationBuilder = NotificationBuilder('my title'); $notificationBuilder->setBody('Hello world') ->setSound('default'); $notification = $notificationBuilder->build();, (*13)

$token = "a_registration_from_your_database"; $downstreamResponse = FCM::sendTo($token, $notification);, (*14)

if ($downstreamResponse->isSent == 1) { echo "The message has been sent."; } else { echo "The message could not be sent." } ````, (*15)

Licence

This library is open-sourced software licensed under the MIT license., (*16)

Some of this documentation is coming from the official documentation. You can find it completely on the Firebase Cloud Messaging Website., (*17)

The Versions

11/07 2018

dev-master

9999999-dev

Laravel FCM Package

  Sources   Download

MIT

by Simon Shrestha