Download the PHP package canerdogan/laravel-notification-channel-fcm without Composer

On this page you can find all versions of the php package canerdogan/laravel-notification-channel-fcm. 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-notification-channel-fcm

Laravel FCM (Firebase Cloud Messaging) Notification Channel

Latest Version on Packagist StyleCI SensioLabsInsight Quality Score Total Downloads

This package makes it easy to send notifications using Firebase Cloud Messaging (FCM) with Laravel 5.3, 5.4, and 5.5.

Contents

Installation

Install this package with Composer:

composer require coreproc/laravel-notification-channel-fcm

Register the ServiceProvider in your config/app.php (Skip this step if you are using Laravel 5.5):

NotificationChannels\Fcm\FcmServiceProvider::class,

Setting up the FCM service

You need to register for a server key from Firebase for your application. Start by creating a project here: https://console.firebase.google.com

Once you've registered and set up your prroject, add the API key to your configuration in config/broadcasting.php

'connections' => [
    ....
    'fcm' => [
        'key' => env('FCM_KEY'),
    ],
    ...
]

Usage

You can now send notifications via FCM by creating an FcmNotification and an FcmMessages:

You will have to set a routeNotificationForFcm() method in your notifiable model. For example:

Once you have that in place, you can simply send a notification to the user via

Available Message methods

The Message object can differ between different operating systems (Android, iOS, and Chrome). In this perspective, a Message object is available for each platform which extends the FcmMessage object.

Mostly all the methods below are explained and defined in the Firebase Cloud Messaging documentation found here: https://firebase.google.com/docs/cloud-messaging/http-server-ref

FcmMessage

This method can be used to override the default FCM key defined in the config/broadcasting.php file.

This parameter specifies a logical expression of conditions that determine the message target. Supported condition: Topic, formatted as "'yourTopic' in topics". This value is case-insensitive. Supported operators: &&, ||. Maximum two operators per topic message supported.

This parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can be collapsed, so that only the last message gets sent when delivery can be resumed. This is intended to avoid sending too many of the same messages when the device comes back online or becomes active.

Note that there is no guarantee of the order in which messages get sent.

Note: A maximum of 4 different collapse keys is allowed at any given time. This means a FCM connection server can simultaneously store 4 different send-to-sync messages per client app. If you exceed this number, there is no guarantee which 4 collapse keys the FCM connection server will keep.

On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken.

Currently for iOS 10+ devices only. On iOS, use this field to represent mutable-content in the APNS payload. When a notification is sent and this is set to true, the content of the notification can be modified before it is displayed, using a Notification Service app extension.

Sets the priority of the message. Valid values are FcmMessage::PRIORITY_NORMAL and FcmMessage::PRIORITY::HIGH. On iOS, these correspond to APNs priorities 5 and 10.

By default, notification messages are sent with high priority, and data messages are sent with normal priority. Normal priority optimizes the client app's battery consumption and should be used unless immediate delivery is required. For messages with normal priority, the app may receive the message with unspecified delay.

When a message is sent with high priority, it is sent immediately, and the app can wake a sleeping device and open a network connection to your server.

This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks.

This parameter, when set to true, allows developers to test a request without actually sending a message. Default value is false.

This parameter specifies the custom key-value pairs of the message's payload.

For example, with data:{"score":"3x1"}: On iOS, if the message is sent via APNS, it represents the custom data fields. If it is sent via FCM connection server, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

On Android, this would result in an intent extra named score with the string value 3x1.

The key should not be a reserved word ("from" or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string.

This parameter specifies the predefined, user-visible key-value pairs of the notification payload.

Available Notification Methods

Each FcmMessage object expects an optional notification object which holds the content of the notification. A notification object for each platform is available which extends a main FcmNotification object.

FcmNotification

The notification's title. This field is not visible on iOS phones and tablets.

The notification's body text.

iOS: The action associated with a user click on the notification. Corresponds to category in the APNs payload.

Android: The action associated with a user click on the notification. If specified, an activity with a matching intent filter is launched when a user clicks on the notification.

Web: The action associated with a user click on the notification. For all URL values, secure HTTPS is required.

The notification's channel id (new in Android O).

The app must create a channel with this ID before any notification with this key is received.

If you don't send this key in the request, or if the channel id provided has not yet been created by your app, FCM uses the channel id specified in your app manifest.

The notification's icon.

Android: Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest.

Web: The URL to use for the notification's icon.

This is an iOS specific variable. The value of the badge on the home screen app icon.

If not specified, the badge is not changed.

If set to 0, the badge is removed.

The sound to play when the device receives the notification.

Android: Supports "default" or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/.

iOS: Sound files can be in the main bundle of the client app or in the Library/Sounds folder of the app's data container.

Identifier used to replace existing notifications in the notification drawer.

If not specified, each request creates a new notification.

If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer.

The notification's icon color, expressed in #rrggbb format.

The key to the body string in the app's string resources to use to localize the body text to the user's current localization.

The key to the title string in the app's string resources to use to localize the title text to the user's current localization.

Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization.

Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

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 see License File for more information.


All versions of laravel-notification-channel-fcm with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.4
guzzlehttp/guzzle Version ^6.2
illuminate/notifications Version ^5.3|^5.4|^5.5|^5.6|^5.7|^5.8|^6.0
illuminate/support Version ^5.1|^5.2|^5.3|^5.4|^5.5|^5.6|^5.7|^5.8|^6.0
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 canerdogan/laravel-notification-channel-fcm contains the following files

Loading the files please wait ....