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);
|
||||
|
17
vendor/brozot/laravel-fcm/composer.json
vendored
17
vendor/brozot/laravel-fcm/composer.json
vendored
@@ -12,9 +12,9 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"illuminate/support": "5.*",
|
||||
"illuminate/support": "5.*|^6",
|
||||
"guzzlehttp/guzzle": "~6.0",
|
||||
"monolog/monolog": "^1.19"
|
||||
"monolog/monolog": "^1.12|^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery" : "0.9.*",
|
||||
@@ -34,5 +34,16 @@
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
"prefer-stable": true,
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"LaravelFCM\\FCMServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"FCM": "LaravelFCM\\Facades\\FCM",
|
||||
"FCMGroup": "LaravelFCM\\Facades\\FCMGroup"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace LaravelFCM;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use LaravelFCM\Sender\FCMGroup;
|
||||
use LaravelFCM\Sender\FCMSender;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@@ -12,7 +13,7 @@ class FCMServiceProvider extends ServiceProvider
|
||||
|
||||
public function boot()
|
||||
{
|
||||
if (str_contains($this->app->version(), 'Lumen')) {
|
||||
if (Str::contains($this->app->version(), 'Lumen')) {
|
||||
$this->app->configure('fcm');
|
||||
} else {
|
||||
$this->publishes([
|
||||
@@ -23,7 +24,7 @@ class FCMServiceProvider extends ServiceProvider
|
||||
|
||||
public function register()
|
||||
{
|
||||
if (!str_contains($this->app->version(), 'Lumen')) {
|
||||
if (!Str::contains($this->app->version(), 'Lumen')) {
|
||||
$this->mergeConfigFrom(__DIR__.'/../config/fcm.php', 'fcm');
|
||||
}
|
||||
|
||||
|
@@ -93,6 +93,7 @@ class OptionsBuilder
|
||||
* @return \LaravelFCM\Message\OptionsBuilder
|
||||
*
|
||||
* @throws InvalidOptionsException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
@@ -160,12 +161,12 @@ class OptionsBuilder
|
||||
*
|
||||
* @return \LaravelFCM\Message\OptionsBuilder
|
||||
*
|
||||
* @throws InvalidOptionException
|
||||
* @throws InvalidOptionsException
|
||||
*/
|
||||
public function setTimeToLive($timeToLive)
|
||||
{
|
||||
if ($timeToLive < 0 || $timeToLive > 2419200) {
|
||||
throw new InvalidOptionException("time to live must be between 0 and 2419200, current value is: {$timeToLive}");
|
||||
throw new InvalidOptionsException("time to live must be between 0 and 2419200, current value is: {$timeToLive}");
|
||||
}
|
||||
$this->timeToLive = $timeToLive;
|
||||
|
||||
@@ -309,6 +310,8 @@ final class OptionsPriorities
|
||||
|
||||
/**
|
||||
* @return array priorities available in fcm
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function getPriorities()
|
||||
{
|
||||
@@ -323,6 +326,8 @@ final class OptionsPriorities
|
||||
* @param $priority
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public static function isValid($priority)
|
||||
{
|
||||
|
@@ -146,8 +146,10 @@ class PayloadNotification implements Arrayable
|
||||
];
|
||||
|
||||
// remove null values
|
||||
$notification = array_filter($notification);
|
||||
|
||||
$notification = array_filter($notification, function($value) {
|
||||
return $value !== null;
|
||||
});
|
||||
|
||||
return $notification;
|
||||
}
|
||||
}
|
||||
|
@@ -376,7 +376,7 @@ class DownstreamResponse extends BaseResponse implements DownstreamResponseContr
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tokens that you should resend using exponential backoof.
|
||||
* Get tokens that you should resend using exponential backoff.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -105,7 +105,7 @@ class FCMSender extends HTTPSender
|
||||
*
|
||||
* @return null|\Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
private function post($request)
|
||||
protected function post($request)
|
||||
{
|
||||
try {
|
||||
$responseGuzzle = $this->client->request('post', $this->url, $request->build());
|
||||
|
13
vendor/brozot/laravel-fcm/tests/MessageTest.php
vendored
13
vendor/brozot/laravel-fcm/tests/MessageTest.php
vendored
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use LaravelFCM\Message\Exceptions\InvalidOptionsException;
|
||||
use LaravelFCM\Message\OptionsBuilder;
|
||||
use LaravelFCM\Message\OptionsPriorities;
|
||||
use LaravelFCM\Message\PayloadDataBuilder;
|
||||
@@ -127,4 +128,16 @@ class PayloadTest extends FCMTestCase
|
||||
$json = json_encode($notificationBuilder->build()->toArray());
|
||||
$this->assertJsonStringEqualsJsonString($targetFull, $json);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_throws_an_invalidoptionsexception_if_the_interval_is_too_big()
|
||||
{
|
||||
$this->setExpectedException(InvalidOptionsException::class);
|
||||
|
||||
$optionBuilder = new OptionsBuilder();
|
||||
$optionBuilder->setTimeToLive(2419200 * 10);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -79,7 +79,7 @@ class MockTopicResponse implements TopicResponseContract
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
$this->error;
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,6 +89,6 @@ class MockTopicResponse implements TopicResponseContract
|
||||
*/
|
||||
public function shouldRetry()
|
||||
{
|
||||
$this->error;
|
||||
return (bool) $this->error;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user