updated-packages
This commit is contained in:
74
vendor/brozot/laravel-fcm/README.md
vendored
74
vendor/brozot/laravel-fcm/README.md
vendored
@@ -5,7 +5,7 @@
|
||||
|
||||
## Introduction
|
||||
|
||||
Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/) (FCM).
|
||||
Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/) (FCM).
|
||||
|
||||
It currently **only supports HTTP protocol** for :
|
||||
|
||||
@@ -26,23 +26,26 @@ To get the latest version of Laravel-FCM on your project, require it from "compo
|
||||
|
||||
Or you can add it directly in your composer.json file:
|
||||
|
||||
|
||||
{
|
||||
"require": {
|
||||
"brozot/laravel-fcm": "1.2.*"
|
||||
}
|
||||
}
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"brozot/laravel-fcm": "1.3.*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Laravel
|
||||
|
||||
Register the provider directly in your app configuration file config/app.php `config/app.php`:
|
||||
|
||||
Laravel >= 5.5 provides package auto-discovery, thanks to rasmuscnielsen and luiztessadri who help to implement this feature in Laravel-FCM, the registration of the provider and the facades should not be necessary anymore.
|
||||
|
||||
```php
|
||||
'providers' => [
|
||||
// ...
|
||||
|
||||
LaravelFCM\FCMServiceProvider::class
|
||||
|
||||
LaravelFCM\FCMServiceProvider::class,
|
||||
]
|
||||
```
|
||||
|
||||
@@ -61,14 +64,14 @@ Add the facade aliases in the same file:
|
||||
Publish the package config file using the following command:
|
||||
|
||||
|
||||
$ php artisan vendor:publish
|
||||
$ php artisan vendor:publish --provider="LaravelFCM\FCMServiceProvider"
|
||||
|
||||
|
||||
### Lumen
|
||||
|
||||
Register the provider in your boostrap app file ```boostrap/app.php```
|
||||
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.
|
||||
Add the following line in the "Register Service Providers" section at the bottom of the file.
|
||||
|
||||
```php
|
||||
$app->register(LaravelFCM\FCMServiceProvider::class);
|
||||
@@ -130,7 +133,7 @@ $optionBuilder->setTimeToLive(60*20);
|
||||
$notificationBuilder = new PayloadNotificationBuilder('my title');
|
||||
$notificationBuilder->setBody('Hello world')
|
||||
->setSound('default');
|
||||
|
||||
|
||||
$dataBuilder = new PayloadDataBuilder();
|
||||
$dataBuilder->addData(['a_data' => 'my_data']);
|
||||
|
||||
@@ -146,16 +149,17 @@ $downstreamResponse->numberSuccess();
|
||||
$downstreamResponse->numberFailure();
|
||||
$downstreamResponse->numberModification();
|
||||
|
||||
//return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete();
|
||||
// return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete();
|
||||
|
||||
//return Array (key : oldToken, value : new token - you must change the token in your database )
|
||||
$downstreamResponse->tokensToModify();
|
||||
// return Array (key : oldToken, value : new token - you must change the token in your database)
|
||||
$downstreamResponse->tokensToModify();
|
||||
|
||||
//return Array - you should try to resend the message to the tokens in the array
|
||||
// return Array - you should try to resend the message to the tokens in the array
|
||||
$downstreamResponse->tokensToRetry();
|
||||
|
||||
// return Array (key:token, value:errror) - in production you should remove from your database the tokens
|
||||
// return Array (key:token, value:error) - in production you should remove from your database the tokens
|
||||
$downstreamResponse->tokensWithError();
|
||||
```
|
||||
|
||||
#### Sending a Downstream Message to Multiple Devices
|
||||
@@ -167,7 +171,7 @@ $optionBuilder->setTimeToLive(60*20);
|
||||
$notificationBuilder = new PayloadNotificationBuilder('my title');
|
||||
$notificationBuilder->setBody('Hello world')
|
||||
->setSound('default');
|
||||
|
||||
|
||||
$dataBuilder = new PayloadDataBuilder();
|
||||
$dataBuilder->addData(['a_data' => 'my_data']);
|
||||
|
||||
@@ -178,25 +182,27 @@ $data = $dataBuilder->build();
|
||||
// You must change it to get your tokens
|
||||
$tokens = MYDATABASE::pluck('fcm_token')->toArray();
|
||||
|
||||
$downstreamResponse = FCM::sendTo($tokens, $option, $notification);
|
||||
$downstreamResponse = FCM::sendTo($tokens, $option, $notification, $data);
|
||||
|
||||
$downstreamResponse->numberSuccess();
|
||||
$downstreamResponse->numberFailure();
|
||||
$downstreamResponse->numberFailure();
|
||||
$downstreamResponse->numberModification();
|
||||
|
||||
//return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete();
|
||||
// return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete();
|
||||
|
||||
//return Array (key : oldToken, value : new token - you must change the token in your database )
|
||||
$downstreamResponse->tokensToModify();
|
||||
// return Array (key : oldToken, value : new token - you must change the token in your database)
|
||||
$downstreamResponse->tokensToModify();
|
||||
|
||||
//return Array - you should try to resend the message to the tokens in the array
|
||||
// return Array - you should try to resend the message to the tokens in the array
|
||||
$downstreamResponse->tokensToRetry();
|
||||
|
||||
// return Array (key:token, value:errror) - in production you should remove from your database the tokens present in this array
|
||||
$downstreamResponse->tokensWithError();
|
||||
// return Array (key:token, value:error) - in production you should remove from your database the tokens present in this array
|
||||
$downstreamResponse->tokensWithError();
|
||||
```
|
||||
|
||||
> Kindly refer [Downstream message error response codes](https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes) documentation for more information.
|
||||
|
||||
### Topics Messages
|
||||
|
||||
A topics message is a notification message, data message, or both, that you send to all the devices registered to this topic.
|
||||
@@ -215,17 +221,17 @@ use LaravelFCM\Message\Topics;
|
||||
$notificationBuilder = new PayloadNotificationBuilder('my title');
|
||||
$notificationBuilder->setBody('Hello world')
|
||||
->setSound('default');
|
||||
|
||||
|
||||
$notification = $notificationBuilder->build();
|
||||
|
||||
$topic = new Topics();
|
||||
$topic->topic('news');
|
||||
|
||||
$topicResponse = FCM::sendToTopic($topic, null, $notification, null)
|
||||
$topicResponse = FCM::sendToTopic($topic, null, $notification, null);
|
||||
|
||||
$topicResponse->isSuccess();
|
||||
$topicResponse->shouldRetry();
|
||||
$topicResponse->error());
|
||||
$topicResponse->error();
|
||||
```
|
||||
|
||||
#### Sending a Message to Multiple Topics
|
||||
@@ -241,14 +247,14 @@ It sends notification to devices registered at the following topics:
|
||||
$notificationBuilder = new PayloadNotificationBuilder('my title');
|
||||
$notificationBuilder->setBody('Hello world')
|
||||
->setSound('default');
|
||||
|
||||
|
||||
$notification = $notificationBuilder->build();
|
||||
|
||||
$topic = new Topics();
|
||||
$topic->topic('news')->andTopic(function($condition) {
|
||||
|
||||
$condition->topic('economic')->orTopic('cultural');
|
||||
|
||||
|
||||
});
|
||||
|
||||
$topicResponse = FCM::sendToTopic($topic, null, $notification, null);
|
||||
|
Reference in New Issue
Block a user