Download the PHP package nylo/laravel-fcm-channel without Composer

On this page you can find all versions of the php package nylo/laravel-fcm-channel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-fcm-channel

Laravel FCM Channel

Manage FCM notifications with ease using Laravel FCM Channel.

Contents

This package has been built to make sending FCM messages easier.

There is also a Flutter package you can use to save time for mobile development.

Overview:

Installation

First, install the package via composer:

The package will automatically register itself.

Configuration

Run the install command.

This will add a (laravelfcm.php) config file

ServiceProvider to your app.php: App\Providers\FcmAppServiceProvider::class

Then, ask if you want to run the migrations.

Here are the tables it will migrate:

Add your Google Service Account to config/firebase_service_account_json.

You can download your Google Service Account in your Firebase Project Settings > Service Accounts > Manage service account permissions > "Actions (three dots) - Manage keys" > Add Key > Create New Key.

Then, paste the JSON into the firebase_service_account_json file like in the above example.

Note: It's best to keep the key values in a .env file. Don't commit the JSON file to your repository.

You can configure this package in config/laravelfcm.php.

Configuring your Model

Add the HasFcmDevices trait to your User Model.

This package uses laravel/sanctum as the default middleware for your model.

However, if you want authenticate using a different middleware, you can update the middleware key in your config/laravelfcm.php file.

API Endpoints

This package adds API endpoints to your router to allow your application to store devices.

Postman collection example


Store a device

The default endpoint: /api/fcm/device

Method: PUT

Authorization: "Bearer {{Sanctum Token}}"

Add this header key: X-DMeta

Value:

Payload body:

This will add a new FCM device for a User. If you provide a fcm_token in the payload then the user will be able to receive push notifications.

Usage

Sending Notifications

To send a notification using the FCMChannel, first create a Notification in your Laravel project.

After creating your notification, add a fcm_channel to the array below.

Then, add the following snippet to your notification class.

Send a Notification

This will send a notification to the user's devices.

Control if an FCM notification should be sent

In some scenarios, you may only want to notify a user based on a condition.

In your User model class, add the following snippet.

By default, the canSendNotification method will return true.

Notification Object

Here are the attributes you can assign to a FcmMessage.

Relationships

When your model is using the HasFcmDevices trait you can call the following methods.

Flutter Plugin

Need to send notifications to a Flutter application?

Check out the official repository for that project here.

Changelog

Please see CHANGELOG for recent changes.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please view our License File for more information.


All versions of laravel-fcm-channel with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
illuminate/support Version ~5.8.0|6.x|7.x|8.x|9.x|10.x|11.x
kreait/firebase-php Version ^7.12
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nylo/laravel-fcm-channel contains the following files

Loading the files please wait ....