MuhBayu / laravel-firebase-cloud-messaging by mbn12

Package Firebase Cloud Messaging for Laravel/Lumen
0
0
1
Package Data
Maintainer Username: mbn12
Maintainer Contact: bnugraha00@hotmail.com (MuhBayu)
Package Create Date: 2018-12-14
Package Last Update: 2018-12-17
Language: PHP
License: Unknown
Last Refreshed: 2024-03-27 03:13:51
Package Statistics
Total Downloads: 0
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

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);