LaravelPackages.net
Acme Inc.
Toggle sidebar
muhbayu/laravel-firebase-cloud-messaging

Package Firebase Cloud Messaging for Laravel/Lumen

0
0
About muhbayu/laravel-firebase-cloud-messaging

muhbayu/laravel-firebase-cloud-messaging is a Laravel package for package firebase cloud messaging for laravel/lumen. It currently has 0 GitHub stars and 0 downloads on Packagist. Install it with composer require muhbayu/laravel-firebase-cloud-messaging. Discover more Laravel packages by muhbayu or browse all Laravel packages to compare alternatives.

Last updated

Laravel Firebase Cloud Messaging

Instalation

To get the latest version of FCM on your project, require it from "composer":

$ composer require muhbayu\laravel-firebase-cloud-messaging

Laravel

Register the provider directly in your app configuration file config/app.php

'providers' => [
	 // ...
	 MuhBayu\Fcm\FcmServiceProvider::class,
]

Publish the package config file using the following command:

$ php artisan vendor:publish --provider="MuhBayu\Fcm\FcmServiceProvider"

Lumen

Register the provider in your bootstrap app file boostrap/app.php Add the following line in the "Register Service Providers" section at the bottom of the file:

$app->register(MuhBayu\Fcm\FcmServiceProvider::class);

Package Configuration

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

FCM_LEGACY_KEY=<your_server_Key> FCM_SENDER_ID=<your_sender_id>

Basic Usage

The following use statements are required for the examples below:

use MuhBayu\Fcm;

Sending Push Notification

// if you want to send multiple $recipients token must an array 
Fcm::to($recipients)->notification([
	'title' => 'Title Message',
	'body' => 'This is a body message of FCM',
	'click_action' => 'http://yourdomain.com', // optional
	'icon' => 'your_icon', //optional
])->send();

If You want to send a FCM to topic, use method

->topic('/topic/name')

Notification with Extra Data

If you want to send a FCM with data & notification parameter, you must use extra method :

Fcm::to($recipients)->notification([
	// ...
])->extra([
	'name' => 'Name Data',
	'data' => 'Data test',
])->send();

Simple Usage

fcm()->send($notification, $data);

Star History Chart