PHPackages                             saikatdutta1991/firebasecloudmessaging - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. saikatdutta1991/firebasecloudmessaging

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

saikatdutta1991/firebasecloudmessaging
======================================

This is to send push notification with firebase cloud messaging for Laravel. Tested in Laravel 5.2.\*

1.0.0(9y ago)2212PHP

Since Mar 19Pushed 5y ago2 watchersCompare

[ Source](https://github.com/saikatdutta1991/FirebaseCloudMessaging)[ Packagist](https://packagist.org/packages/saikatdutta1991/firebasecloudmessaging)[ RSS](/packages/saikatdutta1991-firebasecloudmessaging/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Firebase Cloud Messaging
========================

[](#firebase-cloud-messaging)

\*\* Caveat: This package is not maintained anymore.

This Package is to enable sending push notifications to devices with firebase cloud messaging. Tested in Laravel 5.1 and 5.2

\#Installation
--------------

[](#installation)

To install the package simply run this command in Laravel project root folder

```
php composer.phar require saikatdutta1991/firebasecloudmessaging:1.0.0
```

add the service provider

```
    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */

        .....
        .....
        \Saikat\FirebaseCloudMessaging\FCMServiceProvider::class
    ]
```

to `config\app.php` providers array

Alias the PushManager class adding it to the aliases array in the `config/app.php` file.

```
    'aliases' => [
        ...
        'PushManager' => Saikat\FirebaseCloudMessaging\PushManager::class
    ]
```

But the alias is not mandatory.

Configuration
=============

[](#configuration)

publish the package config to your laravel config folder with executing command

```
php artisan vendor:publish --tag="config"
```

before executing this command add the service provider first

add the fcm `server_key` in the `config/firebase_cloud_messaging.php` file

```
    return [

        "server_key" => env('FIREBASE_CLOUD_MESSAGING_SERVER_KEY'),
        "fcm_push_url" => env("FIREBASE_CLOUD_MESSAING_URL")

    ];
```

`fcm_push_url` is not required already included in package. If want to override then add it

Usage
=====

[](#usage)

---

\##including PushManager
------------------------

[](#including-pushmanager)

If added in alias then use it in controller

```
use PushManager;
```

IF not added in alias then use it in controller

```
use Saikat\FirebaseCloudMessaging\PushManager;
```

\##dependency injection in controller constructor
-------------------------------------------------

[](#dependency-injection-in-controller-constructor)

```
class YourController extends Controller
{

    public function __construct(PushManager $pushManager)
    {
        $this->pushManager = $pushManager;
    }
```

If want to use without injecting then

```
class YourController extends Controller
{

    public function sendPushNotification()
    {
        $pushManager = app('PushManager'); // this will keep the PushManager instance singleton
    }
```

Example
=======

[](#example)

```
