update 1.0.8.0
Commits for version update
This commit is contained in:
1
vendor/brozot/laravel-fcm/.gitignore
vendored
1
vendor/brozot/laravel-fcm/.gitignore
vendored
@@ -15,6 +15,7 @@ storage/debugbar
|
||||
doc/generated/*
|
||||
generatedoc.sh
|
||||
phpdoc.xml
|
||||
build/*
|
||||
|
||||
# Editors
|
||||
.sublime-workspace
|
||||
|
||||
6
vendor/brozot/laravel-fcm/.travis.yml
vendored
6
vendor/brozot/laravel-fcm/.travis.yml
vendored
@@ -4,9 +4,11 @@ php:
|
||||
- 5.6
|
||||
|
||||
before_script:
|
||||
- mysql -e 'create database homestead_test;'
|
||||
- composer self-update
|
||||
- composer install --no-interaction
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit
|
||||
- phpunit --coverage-clover build/logs/clover.xml
|
||||
|
||||
after_success:
|
||||
- travis_retry php vendor/bin/coveralls
|
||||
253
vendor/brozot/laravel-fcm/README.md
vendored
253
vendor/brozot/laravel-fcm/README.md
vendored
@@ -1,57 +1,54 @@
|
||||
# Laravel-FCM
|
||||
|
||||
[](https://travis-ci.org/brozot/Laravel-FCM) [](https://packagist.org/packages/brozot/laravel-fcm) [](https://packagist.org/packages/brozot/laravel-fcm)
|
||||
[](https://travis-ci.org/brozot/Laravel-FCM) [](https://coveralls.io/github/brozot/Laravel-FCM?branch=master) [](https://packagist.org/packages/brozot/laravel-fcm) [](https://packagist.org/packages/brozot/laravel-fcm)
|
||||
[](https://packagist.org/packages/brozot/laravel-fcm)
|
||||
|
||||
## 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 supports :
|
||||
It currently **only supports HTTP protocol** for :
|
||||
|
||||
**Http protocol**
|
||||
|
||||
- Sending a downstream message to one or multiple devices
|
||||
- Manage groups and sending message to a group
|
||||
- Sending topics message
|
||||
- sending a downstream message to one or multiple devices
|
||||
- managing groups and sending message to a group
|
||||
- sending topics messages
|
||||
|
||||
> Note: The XMPP protocol is not currently supported.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
To get the latest version of Laravel-FCM on your project, require it from "composer".
|
||||
To get the latest version of Laravel-FCM on your project, require it from "composer":
|
||||
|
||||
```
|
||||
$ composer require brozot/laravel-fcm
|
||||
```
|
||||
|
||||
or you can add it directly in your composer.json file:
|
||||
$ composer require brozot/laravel-fcm
|
||||
|
||||
|
||||
Or you can add it directly in your composer.json file:
|
||||
|
||||
|
||||
{
|
||||
"require": {
|
||||
"brozot/laravel-fcm": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
{
|
||||
"require": {
|
||||
"brozot/laravel-fcm": "^1.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Laravel
|
||||
|
||||
Register the provider directly in your app configuration file config/app.php ```config/app.php```
|
||||
Register the provider directly in your app configuration file config/app.php `config/app.php`:
|
||||
|
||||
```
|
||||
```php
|
||||
'providers' => [
|
||||
...
|
||||
// ...
|
||||
|
||||
LaravelFCM\FCMServiceProvider::class
|
||||
]
|
||||
```
|
||||
|
||||
Add the facades in the same file.
|
||||
Add the facade aliases in the same file:
|
||||
|
||||
You need to add the facade **"FCMGroup"**, only if you want managing groups message in your application.
|
||||
|
||||
```
|
||||
```php
|
||||
'aliases' => [
|
||||
...
|
||||
'FCM' => LaravelFCM\Facades\FCM::class,
|
||||
@@ -59,11 +56,13 @@ You need to add the facade **"FCMGroup"**, only if you want managing groups mess
|
||||
]
|
||||
```
|
||||
|
||||
Publish the fcm config file with the following command:
|
||||
> Note: The `FCMGroup` facade is needed only if you want to manage groups messages in your application.
|
||||
|
||||
Publish the package config file using the following command:
|
||||
|
||||
|
||||
$ php artisan vendor:publish
|
||||
|
||||
```
|
||||
$ php artisan vendor:publish
|
||||
```
|
||||
|
||||
### Lumen
|
||||
|
||||
@@ -71,13 +70,13 @@ Register the provider in your boostrap app file ```boostrap/app.php```
|
||||
|
||||
Add the following line in the "Register Service Providers" section at the bottom of the file.
|
||||
|
||||
```
|
||||
```php
|
||||
$app->register(LaravelFCM\FCMServiceProvider::class);
|
||||
```
|
||||
|
||||
For facades, add the following lines in the section "Create The Application" . FCMGroup facade is only necessary if you want to use groups message in your application.
|
||||
|
||||
```
|
||||
```php
|
||||
class_alias(\LaravelFCM\Facades\FCM::class, 'FCM');
|
||||
class_alias(\LaravelFCM\Facades\FCMGroup::class, 'FCMGroup');
|
||||
```
|
||||
@@ -85,39 +84,46 @@ class_alias(\LaravelFCM\Facades\FCMGroup::class, 'FCMGroup');
|
||||
Copy the config file ```fcm.php``` manually from the directory ```/vendor/brozot/laravel-fcm/config``` to the directory ```/config ``` (you may need to create this directory).
|
||||
|
||||
|
||||
### Configure package
|
||||
### Package Configuration
|
||||
|
||||
In your ```.env``` file add the server key and the secret key for Firebase cloud messaging.
|
||||
In your `.env` file, add the server key and the secret key for the Firebase Cloud Messaging:
|
||||
|
||||
example :
|
||||
```
|
||||
```php
|
||||
FCM_SERVER_KEY=my_secret_server_key
|
||||
FCM_SENDER_ID=my_secret_sender_id
|
||||
```
|
||||
|
||||
To get these keys, you must create a new application on the [firebase cloud messaging console](https://console.firebase.google.com/).
|
||||
|
||||
After the creation of your application on firebase, you can find keys in: ```project settings -> cloud messaging```.
|
||||
|
||||
## Basic usage
|
||||
|
||||
Sending message :
|
||||
|
||||
With Laravel-FCM, you can send two types of messages:
|
||||
|
||||
- Notification messages, sometimes thought of as "display messages."
|
||||
- Data messages, which are handled by the client app.
|
||||
|
||||
you can find more information with the [official documentation](https://firebase.google.com/docs/cloud-messaging/concept-options)
|
||||
After the creation of your application on Firebase, you can find keys in `project settings -> cloud messaging`.
|
||||
|
||||
|
||||
### Downstream Message
|
||||
## Basic Usage
|
||||
|
||||
Downstream message is a notification message, a data message or both that you send to a target device or to multiple targets devices using it (them) registration_Ids.
|
||||
Two types of messages can be sent using Laravel-FCM:
|
||||
|
||||
**Send a downstream message to a device**
|
||||
- Notification messages, sometimes thought of as "display messages"
|
||||
- Data messages, which are handled by the client app
|
||||
|
||||
More information is available in the [official documentation](https://firebase.google.com/docs/cloud-messaging/concept-options).
|
||||
|
||||
|
||||
### Downstream Messages
|
||||
|
||||
A downstream message is a notification message, a data message, or both, that you send to a target device or to multiple target devices using its registration_Ids.
|
||||
|
||||
The following use statements are required for the examples below:
|
||||
|
||||
```php
|
||||
use LaravelFCM\Message\OptionsBuilder;
|
||||
use LaravelFCM\Message\PayloadDataBuilder;
|
||||
use LaravelFCM\Message\PayloadNotificationBuilder;
|
||||
use FCM;
|
||||
```
|
||||
|
||||
#### Sending a Downstream Message to a Device
|
||||
|
||||
```php
|
||||
$optionBuiler = new OptionsBuilder();
|
||||
$optionBuiler->setTimeToLive(60*20);
|
||||
|
||||
@@ -136,29 +142,25 @@ $token = "a_registration_from_your_database";
|
||||
|
||||
$downstreamResponse = FCM::sendTo($token, $option, $notification, $data);
|
||||
|
||||
$downstreamResponse = new DownstreamResponse($response, $tokens);
|
||||
|
||||
$downstreamResponse->numberSuccess());
|
||||
$downstreamResponse->numberFailure());
|
||||
$downstreamResponse->numberModification());
|
||||
$downstreamResponse->numberSuccess();
|
||||
$downstreamResponse->numberFailure();
|
||||
$downstreamResponse->numberModification();
|
||||
|
||||
//return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete());
|
||||
$downstreamResponse->tokensToDelete();
|
||||
|
||||
//return Array (key : oldToken, value : new token - you must change the token in your database )
|
||||
$downstreamResponse->tokensToModify());
|
||||
$downstreamResponse->tokensToModify();
|
||||
|
||||
//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
|
||||
|
||||
|
||||
```
|
||||
|
||||
**Send a downstream message to multiple devices**
|
||||
#### Sending a Downstream Message to Multiple Devices
|
||||
|
||||
```
|
||||
```php
|
||||
$optionBuiler = new OptionsBuilder();
|
||||
$optionBuiler->setTimeToLive(60*20);
|
||||
|
||||
@@ -178,33 +180,32 @@ $tokens = MYDATABASE::pluck('fcm_token')->toArray();
|
||||
|
||||
$downstreamResponse = FCM::sendTo($tokens, $option, $notification);
|
||||
|
||||
$downstreamResponse->numberSuccess());
|
||||
$downstreamResponse->numberFailure());
|
||||
$downstreamResponse->numberModification());
|
||||
$downstreamResponse->numberSuccess();
|
||||
$downstreamResponse->numberFailure();
|
||||
$downstreamResponse->numberModification();
|
||||
|
||||
//return Array - you must remove all this tokens in your database
|
||||
$downstreamResponse->tokensToDelete());
|
||||
$downstreamResponse->tokensToDelete();
|
||||
|
||||
//return Array (key : oldToken, value : new token - you must change the token in your database )
|
||||
$downstreamResponse->tokensToModify());
|
||||
$downstreamResponse->tokensToModify();
|
||||
|
||||
//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();
|
||||
|
||||
```
|
||||
|
||||
### Topics Message
|
||||
### Topics Messages
|
||||
|
||||
Topics message is a notification message, data message or both, that you send to all the devices registered to this topic.
|
||||
A topics message is a notification message, data message, or both, that you send to all the devices registered to this topic.
|
||||
|
||||
>Topics names must be managed by your app and known by your server. The Laravel-FCM package or fcm doesn't provide an easy way to do that.
|
||||
> Note: Topic names must be managed by your app and known by your server. The Laravel-FCM package or fcm doesn't provide an easy way to do that.
|
||||
|
||||
**Send a message to topic "news"**
|
||||
#### Sending a Message to a Topic
|
||||
|
||||
```
|
||||
```php
|
||||
$notificationBuilder = new PayloadNotificationBuilder('my title');
|
||||
$notificationBuilder->setBody('Hello world')
|
||||
->setSound('default');
|
||||
@@ -219,10 +220,9 @@ $topicResponse = FCM::sendToTopic($topic, null, $notification, null)
|
||||
$topicResponse->isSuccess();
|
||||
$topicResponse->shouldRetry();
|
||||
$topicResponse->error());
|
||||
|
||||
```
|
||||
|
||||
**Send a message to topic "news" and ("economic" or "cultural")**
|
||||
#### Sending a Message to Multiple Topics
|
||||
|
||||
It sends notification to devices registered at the following topics:
|
||||
|
||||
@@ -231,7 +231,7 @@ It sends notification to devices registered at the following topics:
|
||||
|
||||
> Note : Conditions for topics support two operators per expression
|
||||
|
||||
```
|
||||
```php
|
||||
$notificationBuilder = new PayloadNotificationBuilder('my title');
|
||||
$notificationBuilder->setBody('Hello world')
|
||||
->setSound('default');
|
||||
@@ -253,11 +253,11 @@ $topicResponse->error());
|
||||
|
||||
```
|
||||
|
||||
### Group message
|
||||
### Group Messages
|
||||
|
||||
**Send a notification to a group**
|
||||
#### Sending a Notification to a Group
|
||||
|
||||
```
|
||||
```php
|
||||
$notificationKey = ['a_notification_key'];
|
||||
|
||||
|
||||
@@ -273,78 +273,71 @@ $groupResponse = FCM::sendToGroup($notificationKey, null, $notification, null);
|
||||
$groupResponse->numberSuccess();
|
||||
$groupResponse->numberFailure();
|
||||
$groupResponse->tokensFailed();
|
||||
|
||||
|
||||
```
|
||||
|
||||
**Create a group**
|
||||
|
||||
```
|
||||
#### Creating a Group
|
||||
|
||||
```php
|
||||
$tokens = ['a_registration_id_at_add_to_group'];
|
||||
$groupName = "a_group";
|
||||
$notificationKey
|
||||
|
||||
// Save notification key in your database you must use it to send messages or for managing this group
|
||||
$notification_key = FCMGroup::createGroup($groupName, $tokens);
|
||||
|
||||
|
||||
```
|
||||
|
||||
**Add devices in a group**
|
||||
#### Adding Devices to a Group
|
||||
|
||||
```
|
||||
```php
|
||||
$tokens = ['a_registration_id_at_add_to_the_new_group'];
|
||||
$groupName = "a_group";
|
||||
$notificationKey = "notification_key_received_when_group_was_created";
|
||||
|
||||
$key = FCMGroup::addToGroup($groupName, $notificationKey, $tokens);
|
||||
|
||||
|
||||
```
|
||||
|
||||
**Delete devices in a group**
|
||||
#### Deleting Devices from a Group
|
||||
|
||||
> Note if all devices are removed from the group, the group is automatically removed in "fcm".
|
||||
|
||||
```
|
||||
```php
|
||||
$tokens = ['a_registration_id_at_remove_from_the_group'];
|
||||
$groupName = "a_group";
|
||||
$notificationKey = "notification_key_received_when_group_was_created";
|
||||
|
||||
$key = FCMGroup::removeFromGroup($groupName, $notificationKey, $tokens);
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
Laravel-FCM support options based on the options of Firebase cloud messaging. These options can help you to define the specificity of your notification.
|
||||
Laravel-FCM supports options based on the options of Firebase Cloud Messaging. These options can help you to define the specificity of your notification.
|
||||
|
||||
Construct an option
|
||||
You can construct an option as follows:
|
||||
|
||||
```
|
||||
// example
|
||||
```php
|
||||
$optionsBuilder = new OptionsBuilder();
|
||||
|
||||
$optionsBuilder->setTimeToLive(42*60)
|
||||
->setCollapseKey('a_collapse_key');
|
||||
|
||||
$options = $optionsBuilder->build();
|
||||
```
|
||||
|
||||
## Notification message
|
||||
## Notification Messages
|
||||
|
||||
Notification payload is used to send a notification, the behaviour is defined by the App State and the OS of the receptor device.
|
||||
|
||||
**About notification message**
|
||||
|
||||
**Notification messages are delivered to the notification tray when the app is in the background.** For apps in the foreground, messages are handled by these callbacks:
|
||||
|
||||
- didReceiveRemoteNotification: on iOS
|
||||
- onMessageReceived() on Android. The notification key in the data bundle contains the notification.
|
||||
|
||||
[official documentation](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications)
|
||||
See the [official documentation](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications).
|
||||
|
||||
**How construct a notification**
|
||||
|
||||
```
|
||||
```php
|
||||
$notificationBuilder = new PayloadNotificationBuilder();
|
||||
$notificationBuilder->setTitle('title')
|
||||
->setBody('body')
|
||||
@@ -354,20 +347,17 @@ $notificationBuilder->setTitle('title')
|
||||
$notification = $notificationBuilder->build();
|
||||
```
|
||||
|
||||
## Data message
|
||||
|
||||
**About data message**
|
||||
## Data Messages
|
||||
|
||||
Set the data key with your custom key-value pairs to send a data payload to the client app. Data messages can have a 4KB maximum payload.
|
||||
|
||||
- **iOS**, FCM stores the message and delivers it **only when the app is in the foreground** and has established a FCM connection.
|
||||
- **Android**, a client app receives a data message in onMessageReceived() and can handle the key-value pairs accordingly.
|
||||
|
||||
[official documentation](https://firebase.google.com/docs/cloud-messaging/concept-options#data_messages)
|
||||
See the [official documentation](https://firebase.google.com/docs/cloud-messaging/concept-options#data_messages).
|
||||
|
||||
**How construct a data**
|
||||
|
||||
```
|
||||
```php
|
||||
$dataBuilder = new PayloadDataBuilder();
|
||||
$dataBuilder->addData([
|
||||
'data_1' => 'first_data'
|
||||
@@ -376,26 +366,25 @@ $dataBuilder->addData([
|
||||
$data = $dataBuilder->build();
|
||||
```
|
||||
|
||||
## Notification & Data
|
||||
## Notification & Data Messages
|
||||
|
||||
**About both messages**
|
||||
|
||||
App behavior when receiving messages that include both notification and data payloads depends on whether the app is in the background or the foreground—essentially, whether or not it is active at the time of receipt. ([source](https://firebase.google.com/docs/cloud-messaging/concept-options#messages-with-both-notification-and-data-payloads))
|
||||
App behavior when receiving messages that include both notification and data payloads depends on whether the app is in the background or the foreground—essentially, whether or not it is active at the time of receipt ([source](https://firebase.google.com/docs/cloud-messaging/concept-options#messages-with-both-notification-and-data-payloads)).
|
||||
|
||||
- **Background**, apps receive notification payload in the notification tray, and only handle the data payload when the user taps on the notification.
|
||||
- **Foreground**, your app receives a message object with both payloads available.
|
||||
|
||||
|
||||
## Topics
|
||||
|
||||
For topics message, Laravel-FCM offers an easy to use api which abstract firebase conditions. To make the condition given for example in the firebase official documentation it must be done with Laravel-FCM like below:
|
||||
|
||||
*official documentation condition*
|
||||
**Official documentation condition**
|
||||
|
||||
```
|
||||
'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)
|
||||
```
|
||||
|
||||
```
|
||||
```php
|
||||
$topics = new Topics();
|
||||
|
||||
$topics->topic('TopicA')
|
||||
@@ -405,15 +394,41 @@ $topics->topic('TopicA')
|
||||
```
|
||||
|
||||
|
||||
## Testing
|
||||
|
||||
For integration testing, you can mock the responses with mockery and Mocks provided by the package.
|
||||
|
||||
## API
|
||||
There are 3 kinds of "MockResponse" given by the package:
|
||||
|
||||
You can find more documentation about the api with the following link: [Api reference](./doc/Readme.md)
|
||||
- MockDownstreamResponse
|
||||
- MockGroupResponse
|
||||
- MockTopicResponse
|
||||
|
||||
You can mock the FCM call as in the following example:
|
||||
|
||||
```php
|
||||
$numberSucess = 2;
|
||||
$mockResponse = new \LaravelFCM\Mocks\MockDownstreamResponse(numberSucess);
|
||||
|
||||
$mockResponse->addTokenToDelete('token_to_delete');
|
||||
$mockResponse->addTokenToModify('token_to_modify', 'token_modified');
|
||||
$mockResponse->setMissingToken(true);
|
||||
|
||||
$sender = Mockery::mock(\LaravelFCM\Sender\FCMSender::class);
|
||||
$sender->shouldReceive('sendTo')->once()->andReturn($mockResponse);
|
||||
|
||||
$this->app->singleton('fcm.sender', function($app) use($sender) {
|
||||
return $sender;
|
||||
});
|
||||
```
|
||||
|
||||
## API Documentation
|
||||
|
||||
You can find more documentation about the API in the [API reference](./doc/Readme.md).
|
||||
|
||||
|
||||
## Licence
|
||||
|
||||
MIT
|
||||
This library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
||||
|
||||
Some of this documentation is coming from the official documentation. You can find it completly on the firebase cloud messagin website.
|
||||
Some of this documentation is coming from the official documentation. You can find it completely on the [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/) Website.
|
||||
|
||||
5
vendor/brozot/laravel-fcm/composer.json
vendored
5
vendor/brozot/laravel-fcm/composer.json
vendored
@@ -19,12 +19,13 @@
|
||||
"require-dev": {
|
||||
"mockery/mockery" : "0.9.*",
|
||||
"phpunit/phpunit" : "4.7.*",
|
||||
"satooshi/php-coveralls": "dev-master",
|
||||
"laravel/laravel": "5.2.*"
|
||||
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"LaravelFCM\\": "src/"
|
||||
"LaravelFCM\\": "src/",
|
||||
"LaravelFCM\\Mocks\\": "tests/mocks"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
234
vendor/brozot/laravel-fcm/composer.lock
generated
vendored
234
vendor/brozot/laravel-fcm/composer.lock
generated
vendored
@@ -4,8 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "6d4f95c2ddbd6a6a2a1906ae16a42f33",
|
||||
"content-hash": "d68a11dbe5dc18a39247f5c38cee9034",
|
||||
"hash": "e460376d2815b7f406694c5a4f24c8e2",
|
||||
"content-hash": "7dcfa7ab8dfc1522965fbd8381e5abea",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
@@ -1118,23 +1118,23 @@
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v5.4.2",
|
||||
"version": "v5.4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "d8db871a54619458a805229a057ea2af33c753e8"
|
||||
"reference": "4cc92842069c2bbc1f28daaaf1d2576ec4dfe153"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/d8db871a54619458a805229a057ea2af33c753e8",
|
||||
"reference": "d8db871a54619458a805229a057ea2af33c753e8",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/4cc92842069c2bbc1f28daaaf1d2576ec4dfe153",
|
||||
"reference": "4cc92842069c2bbc1f28daaaf1d2576ec4dfe153",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1,<0.9.4"
|
||||
"mockery/mockery": "~0.9.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@@ -1167,7 +1167,7 @@
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"time": "2016-05-01 08:45:47"
|
||||
"time": "2016-07-08 11:51:25"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
@@ -2788,6 +2788,69 @@
|
||||
],
|
||||
"time": "2015-10-02 06:51:40"
|
||||
},
|
||||
{
|
||||
"name": "satooshi/php-coveralls",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/satooshi/php-coveralls.git",
|
||||
"reference": "50c60bb64054974f8ed7540ae6e75fd7981a5fd3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/50c60bb64054974f8ed7540ae6e75fd7981a5fd3",
|
||||
"reference": "50c60bb64054974f8ed7540ae6e75fd7981a5fd3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-simplexml": "*",
|
||||
"guzzlehttp/guzzle": "^6.0",
|
||||
"php": ">=5.5",
|
||||
"psr/log": "^1.0",
|
||||
"symfony/config": "^2.1|^3.0",
|
||||
"symfony/console": "^2.1|^3.0",
|
||||
"symfony/stopwatch": "^2.0|^3.0",
|
||||
"symfony/yaml": "^2.0|^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/http-kernel": "Allows Symfony integration"
|
||||
},
|
||||
"bin": [
|
||||
"bin/coveralls"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Satooshi\\": "src/Satooshi/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kitamura Satoshi",
|
||||
"email": "with.no.parachute@gmail.com",
|
||||
"homepage": "https://www.facebook.com/satooshi.jp"
|
||||
}
|
||||
],
|
||||
"description": "PHP client library for Coveralls API",
|
||||
"homepage": "https://github.com/satooshi/php-coveralls",
|
||||
"keywords": [
|
||||
"ci",
|
||||
"coverage",
|
||||
"github",
|
||||
"test"
|
||||
],
|
||||
"time": "2016-01-20 17:44:41"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "1.2.0",
|
||||
@@ -3160,6 +3223,157 @@
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2015-06-21 13:59:46"
|
||||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
"version": "v3.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/config.git",
|
||||
"reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/config/zipball/bcf5aebabc95b56e370e13d78565f74c7d8726dc",
|
||||
"reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"symfony/filesystem": "~2.8|~3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/yaml": "To use the yaml reference dumper"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Config\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Config Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-06-29 05:41:56"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v3.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/filesystem.git",
|
||||
"reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/322da5f0910d8aa0b25fa65ffccaba68dbddb890",
|
||||
"reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Filesystem\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Filesystem Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-06-29 05:41:56"
|
||||
},
|
||||
{
|
||||
"name": "symfony/stopwatch",
|
||||
"version": "v3.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/stopwatch.git",
|
||||
"reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/bb42806b12c5f89db4ebf64af6741afe6d8457e1",
|
||||
"reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Stopwatch\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Stopwatch Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-06-29 05:41:56"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v3.1.2",
|
||||
@@ -3261,7 +3475,9 @@
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {
|
||||
"satooshi/php-coveralls": 20
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
||||
18
vendor/brozot/laravel-fcm/config/fcm.php
vendored
18
vendor/brozot/laravel-fcm/config/fcm.php
vendored
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'driver' => env('FCM_PROTOCOL','http'),
|
||||
'log_enabled' => true,
|
||||
'driver' => env('FCM_PROTOCOL', 'http'),
|
||||
'log_enabled' => true,
|
||||
|
||||
'http' => [
|
||||
'server_key' => env('FCM_SERVER_KEY','Your FCM server key'),
|
||||
'sender_id' => env('FCM_SENDER_ID', 'Your sender id'),
|
||||
'server_send_url' => 'https://fcm.googleapis.com/fcm/send',
|
||||
'server_group_url' => 'https://android.googleapis.com/gcm/notification',
|
||||
'timeout' => 30.0, // in second
|
||||
]
|
||||
'http' => [
|
||||
'server_key' => env('FCM_SERVER_KEY', 'Your FCM server key'),
|
||||
'sender_id' => env('FCM_SENDER_ID', 'Your sender id'),
|
||||
'server_send_url' => 'https://fcm.googleapis.com/fcm/send',
|
||||
'server_group_url' => 'https://android.googleapis.com/gcm/notification',
|
||||
'timeout' => 30.0, // in second
|
||||
]
|
||||
];
|
||||
|
||||
@@ -9,7 +9,7 @@ Class DownstreamResponse
|
||||
* Class name: DownstreamResponse
|
||||
* Namespace: LaravelFCM\Response
|
||||
* Parent class: [LaravelFCM\Response\BaseResponse](LaravelFCM-Response-BaseResponse.md)
|
||||
|
||||
* This class implements: [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
Constants
|
||||
@@ -171,13 +171,14 @@ parse the response
|
||||
|
||||
### merge
|
||||
|
||||
mixed LaravelFCM\Response\DownstreamResponse::merge(\LaravelFCM\Response\DownstreamResponse $response)
|
||||
mixed LaravelFCM\Response\DownstreamResponseContract::merge(\LaravelFCM\Response\DownstreamResponse $response)
|
||||
|
||||
Merge two response
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
#### Arguments
|
||||
@@ -187,59 +188,63 @@ Merge two response
|
||||
|
||||
### numberSuccess
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponse::numberSuccess()
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberSuccess()
|
||||
|
||||
Get the number of device reached with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### numberFailure
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponse::numberFailure()
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberFailure()
|
||||
|
||||
Get the number of device which thrown an error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### numberModification
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponse::numberModification()
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberModification()
|
||||
|
||||
Get the number of device that you need to modify their token
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensToDelete
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponse::tokensToDelete()
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToDelete()
|
||||
|
||||
get token to delete
|
||||
|
||||
remove all tokens returned by this method in your database
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensToModify
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponse::tokensToModify()
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToModify()
|
||||
|
||||
get token to modify
|
||||
|
||||
@@ -249,26 +254,28 @@ value: new token
|
||||
find the old token in your database and replace it with the new one
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensToRetry
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponse::tokensToRetry()
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToRetry()
|
||||
|
||||
Get tokens that you should resend using exponential backoof
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensWithError
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponse::tokensWithError()
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensWithError()
|
||||
|
||||
Get tokens that thrown an error
|
||||
|
||||
@@ -278,13 +285,14 @@ value : error
|
||||
In production, remove these tokens from you database
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### hasMissingToken
|
||||
|
||||
boolean LaravelFCM\Response\DownstreamResponse::hasMissingToken()
|
||||
boolean LaravelFCM\Response\DownstreamResponseContract::hasMissingToken()
|
||||
|
||||
check if missing tokens was given to the request
|
||||
If true, remove all the empty token in your database
|
||||
@@ -292,6 +300,7 @@ If true, remove all the empty token in your database
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
147
vendor/brozot/laravel-fcm/doc/LaravelFCM-Response-DownstreamResponseContract.md
vendored
Normal file
147
vendor/brozot/laravel-fcm/doc/LaravelFCM-Response-DownstreamResponseContract.md
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
LaravelFCM\Response\DownstreamResponseContract
|
||||
===============
|
||||
|
||||
Interface DownstreamResponseContract
|
||||
|
||||
|
||||
|
||||
|
||||
* Interface name: DownstreamResponseContract
|
||||
* Namespace: LaravelFCM\Response
|
||||
* This is an **interface**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
### merge
|
||||
|
||||
mixed LaravelFCM\Response\DownstreamResponseContract::merge(\LaravelFCM\Response\DownstreamResponse $response)
|
||||
|
||||
Merge two response
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $response **[LaravelFCM\Response\DownstreamResponse](LaravelFCM-Response-DownstreamResponse.md)**
|
||||
|
||||
|
||||
|
||||
### numberSuccess
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberSuccess()
|
||||
|
||||
Get the number of device reached with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### numberFailure
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberFailure()
|
||||
|
||||
Get the number of device which thrown an error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### numberModification
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberModification()
|
||||
|
||||
Get the number of device that you need to modify their token
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensToDelete
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToDelete()
|
||||
|
||||
get token to delete
|
||||
|
||||
remove all tokens returned by this method in your database
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensToModify
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToModify()
|
||||
|
||||
get token to modify
|
||||
|
||||
key: oldToken
|
||||
value: new token
|
||||
|
||||
find the old token in your database and replace it with the new one
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensToRetry
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToRetry()
|
||||
|
||||
Get tokens that you should resend using exponential backoof
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensWithError
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensWithError()
|
||||
|
||||
Get tokens that thrown an error
|
||||
|
||||
key : token
|
||||
value : error
|
||||
|
||||
In production, remove these tokens from you database
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### hasMissingToken
|
||||
|
||||
boolean LaravelFCM\Response\DownstreamResponseContract::hasMissingToken()
|
||||
|
||||
check if missing tokens was given to the request
|
||||
If true, remove all the empty token in your database
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Class GroupResponse
|
||||
* Class name: GroupResponse
|
||||
* Namespace: LaravelFCM\Response
|
||||
* Parent class: [LaravelFCM\Response\BaseResponse](LaravelFCM-Response-BaseResponse.md)
|
||||
|
||||
* This class implements: [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
Constants
|
||||
@@ -114,39 +114,42 @@ Log the response
|
||||
|
||||
### numberSuccess
|
||||
|
||||
integer LaravelFCM\Response\GroupResponse::numberSuccess()
|
||||
integer LaravelFCM\Response\GroupResponseContract::numberSuccess()
|
||||
|
||||
Get the number of device reached with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### numberFailure
|
||||
|
||||
integer LaravelFCM\Response\GroupResponse::numberFailure()
|
||||
integer LaravelFCM\Response\GroupResponseContract::numberFailure()
|
||||
|
||||
Get the number of device which thrown an error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensFailed
|
||||
|
||||
array LaravelFCM\Response\GroupResponse::tokensFailed()
|
||||
array LaravelFCM\Response\GroupResponseContract::tokensFailed()
|
||||
|
||||
Get all token in group that fcm cannot reach
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
59
vendor/brozot/laravel-fcm/doc/LaravelFCM-Response-GroupResponseContract.md
vendored
Normal file
59
vendor/brozot/laravel-fcm/doc/LaravelFCM-Response-GroupResponseContract.md
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
LaravelFCM\Response\GroupResponseContract
|
||||
===============
|
||||
|
||||
Interface GroupResponseContract
|
||||
|
||||
|
||||
|
||||
|
||||
* Interface name: GroupResponseContract
|
||||
* Namespace: LaravelFCM\Response
|
||||
* This is an **interface**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
### numberSuccess
|
||||
|
||||
integer LaravelFCM\Response\GroupResponseContract::numberSuccess()
|
||||
|
||||
Get the number of device reached with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### numberFailure
|
||||
|
||||
integer LaravelFCM\Response\GroupResponseContract::numberFailure()
|
||||
|
||||
Get the number of device which thrown an error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### tokensFailed
|
||||
|
||||
array LaravelFCM\Response\GroupResponseContract::tokensFailed()
|
||||
|
||||
Get all token in group that fcm cannot reach
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Class TopicResponse
|
||||
* Class name: TopicResponse
|
||||
* Namespace: LaravelFCM\Response
|
||||
* Parent class: [LaravelFCM\Response\BaseResponse](LaravelFCM-Response-BaseResponse.md)
|
||||
|
||||
* This class implements: [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
Constants
|
||||
@@ -114,20 +114,21 @@ Log the response
|
||||
|
||||
### isSuccess
|
||||
|
||||
boolean LaravelFCM\Response\TopicResponse::isSuccess()
|
||||
boolean LaravelFCM\Response\TopicResponseContract::isSuccess()
|
||||
|
||||
true if topic sent with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### error
|
||||
|
||||
string LaravelFCM\Response\TopicResponse::error()
|
||||
string LaravelFCM\Response\TopicResponseContract::error()
|
||||
|
||||
return error message
|
||||
you should test if it's necessary to resent it
|
||||
@@ -135,19 +136,21 @@ you should test if it's necessary to resent it
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### shouldRetry
|
||||
|
||||
boolean LaravelFCM\Response\TopicResponse::shouldRetry()
|
||||
boolean LaravelFCM\Response\TopicResponseContract::shouldRetry()
|
||||
|
||||
return true if it's necessary resent it using exponential backoff
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
60
vendor/brozot/laravel-fcm/doc/LaravelFCM-Response-TopicResponseContract.md
vendored
Normal file
60
vendor/brozot/laravel-fcm/doc/LaravelFCM-Response-TopicResponseContract.md
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
LaravelFCM\Response\TopicResponseContract
|
||||
===============
|
||||
|
||||
Interface TopicResponseContract
|
||||
|
||||
|
||||
|
||||
|
||||
* Interface name: TopicResponseContract
|
||||
* Namespace: LaravelFCM\Response
|
||||
* This is an **interface**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
### isSuccess
|
||||
|
||||
boolean LaravelFCM\Response\TopicResponseContract::isSuccess()
|
||||
|
||||
true if topic sent with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### error
|
||||
|
||||
string LaravelFCM\Response\TopicResponseContract::error()
|
||||
|
||||
return error message
|
||||
you should test if it's necessary to resent it
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
|
||||
### shouldRetry
|
||||
|
||||
boolean LaravelFCM\Response\TopicResponseContract::shouldRetry()
|
||||
|
||||
return true if it's necessary resent it using exponential backoff
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
|
||||
254
vendor/brozot/laravel-fcm/doc/LaravelFCM-Test-Mocks-MockDownstreamResponse.md
vendored
Normal file
254
vendor/brozot/laravel-fcm/doc/LaravelFCM-Test-Mocks-MockDownstreamResponse.md
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
LaravelFCM\Test\Mocks\MockDownstreamResponse
|
||||
===============
|
||||
|
||||
Class MockDownstreamResponse **Only use it for testing**
|
||||
|
||||
|
||||
|
||||
|
||||
* Class name: MockDownstreamResponse
|
||||
* Namespace: LaravelFCM\Test\Mocks
|
||||
* This class implements: [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
### __construct
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockDownstreamResponse::__construct($numberSuccess)
|
||||
|
||||
DownstreamResponse constructor.
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $numberSuccess **mixed**
|
||||
|
||||
|
||||
|
||||
### merge
|
||||
|
||||
mixed LaravelFCM\Response\DownstreamResponseContract::merge(\LaravelFCM\Response\DownstreamResponse $response)
|
||||
|
||||
Merge two response
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $response **[LaravelFCM\Response\DownstreamResponse](LaravelFCM-Response-DownstreamResponse.md)**
|
||||
|
||||
|
||||
|
||||
### numberSuccess
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberSuccess()
|
||||
|
||||
Get the number of device reached with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### numberFailure
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberFailure()
|
||||
|
||||
Get the number of device which thrown an error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### numberModification
|
||||
|
||||
integer LaravelFCM\Response\DownstreamResponseContract::numberModification()
|
||||
|
||||
Get the number of device that you need to modify their token
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### addTokenToDelete
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockDownstreamResponse::addTokenToDelete($token)
|
||||
|
||||
Add a token to delete
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $token **mixed**
|
||||
|
||||
|
||||
|
||||
### tokensToDelete
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToDelete()
|
||||
|
||||
get token to delete
|
||||
|
||||
remove all tokens returned by this method in your database
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### addTokenToModify
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockDownstreamResponse::addTokenToModify($oldToken, $newToken)
|
||||
|
||||
Add a token to modify
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $oldToken **mixed**
|
||||
* $newToken **mixed**
|
||||
|
||||
|
||||
|
||||
### tokensToModify
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToModify()
|
||||
|
||||
get token to modify
|
||||
|
||||
key: oldToken
|
||||
value: new token
|
||||
|
||||
find the old token in your database and replace it with the new one
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### addTokenToRetry
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockDownstreamResponse::addTokenToRetry($token)
|
||||
|
||||
Add a token to retry
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $token **mixed**
|
||||
|
||||
|
||||
|
||||
### tokensToRetry
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensToRetry()
|
||||
|
||||
Get tokens that you should resend using exponential backoof
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### addTokenWithError
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockDownstreamResponse::addTokenWithError($token, $message)
|
||||
|
||||
Add a token to errors
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $token **mixed**
|
||||
* $message **mixed**
|
||||
|
||||
|
||||
|
||||
### tokensWithError
|
||||
|
||||
array LaravelFCM\Response\DownstreamResponseContract::tokensWithError()
|
||||
|
||||
Get tokens that thrown an error
|
||||
|
||||
key : token
|
||||
value : error
|
||||
|
||||
In production, remove these tokens from you database
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### setMissingToken
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockDownstreamResponse::setMissingToken($hasMissingToken)
|
||||
|
||||
change missing token state
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $hasMissingToken **mixed**
|
||||
|
||||
|
||||
|
||||
### hasMissingToken
|
||||
|
||||
boolean LaravelFCM\Response\DownstreamResponseContract::hasMissingToken()
|
||||
|
||||
check if missing tokens was given to the request
|
||||
If true, remove all the empty token in your database
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
|
||||
|
||||
|
||||
110
vendor/brozot/laravel-fcm/doc/LaravelFCM-Test-Mocks-MockGroupResponse.md
vendored
Normal file
110
vendor/brozot/laravel-fcm/doc/LaravelFCM-Test-Mocks-MockGroupResponse.md
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
LaravelFCM\Test\Mocks\MockGroupResponse
|
||||
===============
|
||||
|
||||
Class MockGroupResponse **Only use it for testing**
|
||||
|
||||
|
||||
|
||||
|
||||
* Class name: MockGroupResponse
|
||||
* Namespace: LaravelFCM\Test\Mocks
|
||||
* This class implements: [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
### setNumberSuccess
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockGroupResponse::setNumberSuccess($numberSuccess)
|
||||
|
||||
set number of success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $numberSuccess **mixed**
|
||||
|
||||
|
||||
|
||||
### numberSuccess
|
||||
|
||||
integer LaravelFCM\Response\GroupResponseContract::numberSuccess()
|
||||
|
||||
Get the number of device reached with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### setNumberFailure
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockGroupResponse::setNumberFailure($numberFailures)
|
||||
|
||||
set number of failures
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $numberFailures **mixed**
|
||||
|
||||
|
||||
|
||||
### numberFailure
|
||||
|
||||
integer LaravelFCM\Response\GroupResponseContract::numberFailure()
|
||||
|
||||
Get the number of device which thrown an error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### addTokenFailed
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockGroupResponse::addTokenFailed($tokenFailed)
|
||||
|
||||
add a token to the failed list
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $tokenFailed **mixed**
|
||||
|
||||
|
||||
|
||||
### tokensFailed
|
||||
|
||||
array LaravelFCM\Response\GroupResponseContract::tokensFailed()
|
||||
|
||||
Get all token in group that fcm cannot reach
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
|
||||
|
||||
|
||||
95
vendor/brozot/laravel-fcm/doc/LaravelFCM-Test-Mocks-MockTopicResponse.md
vendored
Normal file
95
vendor/brozot/laravel-fcm/doc/LaravelFCM-Test-Mocks-MockTopicResponse.md
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
LaravelFCM\Test\Mocks\MockTopicResponse
|
||||
===============
|
||||
|
||||
Class MockTopicResponse **Only use it for testing**
|
||||
|
||||
|
||||
|
||||
|
||||
* Class name: MockTopicResponse
|
||||
* Namespace: LaravelFCM\Test\Mocks
|
||||
* This class implements: [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
### setSuccess
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockTopicResponse::setSuccess($messageId)
|
||||
|
||||
if success set a message id
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $messageId **mixed**
|
||||
|
||||
|
||||
|
||||
### isSuccess
|
||||
|
||||
boolean LaravelFCM\Response\TopicResponseContract::isSuccess()
|
||||
|
||||
true if topic sent with success
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### setError
|
||||
|
||||
mixed LaravelFCM\Test\Mocks\MockTopicResponse::setError($error)
|
||||
|
||||
set error
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
|
||||
|
||||
#### Arguments
|
||||
* $error **mixed**
|
||||
|
||||
|
||||
|
||||
### error
|
||||
|
||||
string LaravelFCM\Response\TopicResponseContract::error()
|
||||
|
||||
return error message
|
||||
you should test if it's necessary to resent it
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
|
||||
### shouldRetry
|
||||
|
||||
boolean LaravelFCM\Response\TopicResponseContract::shouldRetry()
|
||||
|
||||
return true if it's necessary resent it using exponential backoff
|
||||
|
||||
|
||||
|
||||
* Visibility: **public**
|
||||
* This method is defined by [LaravelFCM\Response\TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
|
||||
|
||||
|
||||
8
vendor/brozot/laravel-fcm/doc/Readme.md
vendored
8
vendor/brozot/laravel-fcm/doc/Readme.md
vendored
@@ -21,10 +21,18 @@ API Index
|
||||
* LaravelFCM\Response
|
||||
* [BaseResponse](LaravelFCM-Response-BaseResponse.md)
|
||||
* [DownstreamResponse](LaravelFCM-Response-DownstreamResponse.md)
|
||||
* [DownstreamResponseContract](LaravelFCM-Response-DownstreamResponseContract.md)
|
||||
* LaravelFCM\Response\Exceptions
|
||||
* [InvalidRequestException](LaravelFCM-Response-Exceptions-InvalidRequestException.md)
|
||||
* [ServerResponseException](LaravelFCM-Response-Exceptions-ServerResponseException.md)
|
||||
* [UnauthorizedRequestException](LaravelFCM-Response-Exceptions-UnauthorizedRequestException.md)
|
||||
* [GroupResponse](LaravelFCM-Response-GroupResponse.md)
|
||||
* [GroupResponseContract](LaravelFCM-Response-GroupResponseContract.md)
|
||||
* [TopicResponse](LaravelFCM-Response-TopicResponse.md)
|
||||
* [TopicResponseContract](LaravelFCM-Response-TopicResponseContract.md)
|
||||
* LaravelFCM\Test
|
||||
* LaravelFCM\Test\Mocks
|
||||
* [MockDownstreamResponse](LaravelFCM-Test-Mocks-MockDownstreamResponse.md)
|
||||
* [MockGroupResponse](LaravelFCM-Test-Mocks-MockGroupResponse.md)
|
||||
* [MockTopicResponse](LaravelFCM-Test-Mocks-MockTopicResponse.md)
|
||||
|
||||
|
||||
13
vendor/brozot/laravel-fcm/src/FCMManager.php
vendored
13
vendor/brozot/laravel-fcm/src/FCMManager.php
vendored
@@ -1,6 +1,5 @@
|
||||
<?php namespace LaravelFCM;
|
||||
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Manager;
|
||||
|
||||
@@ -8,14 +7,14 @@ class FCMManager extends Manager {
|
||||
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['fcm.driver'];
|
||||
return $this->app[ 'config' ][ 'fcm.driver' ];
|
||||
}
|
||||
|
||||
|
||||
protected function createHttpDriver()
|
||||
{
|
||||
$config = $this->app['config']->get('fcm.http', []);
|
||||
return new Client([
|
||||
'timeout' => $config['timeout'],
|
||||
]);
|
||||
$config = $this->app[ 'config' ]->get('fcm.http', []);
|
||||
|
||||
return new Client([ 'timeout' => $config[ 'timeout' ] ]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php namespace LaravelFCM;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use LaravelFCM\Sender\FCMSender;
|
||||
use LaravelFCM\Sender\FCMGroup;
|
||||
use LaravelFCM\Sender\FCMSender;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class FCMServiceProvider extends ServiceProvider {
|
||||
|
||||
protected $defer = true;
|
||||
|
||||
public function boot()
|
||||
{
|
||||
if (str_contains($this->app->version(), 'Lumen')) {
|
||||
@@ -19,27 +21,29 @@ class FCMServiceProvider extends ServiceProvider {
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind('fcm.group', function($app) {
|
||||
return new FCMGroup();
|
||||
});
|
||||
|
||||
$this->app->bind('fcm.sender', function($app) {
|
||||
return new FCMSender();
|
||||
});
|
||||
|
||||
$this->registerClient();
|
||||
}
|
||||
|
||||
public function registerClient()
|
||||
{
|
||||
$this->app->singleton('fcm.client', function($app) {
|
||||
return (new FCMManager($app))->driver();
|
||||
});
|
||||
|
||||
$this->app->bind('fcm.group', function($app) {
|
||||
$client = $app[ 'fcm.client' ];
|
||||
$url = $app[ 'config' ]->get('fcm.http.server_group_url');
|
||||
|
||||
return new FCMGroup($client, $url);
|
||||
});
|
||||
|
||||
$this->app->bind('fcm.sender', function($app) {
|
||||
$client = $app[ 'fcm.client' ];
|
||||
$url = $app[ 'config' ]->get('fcm.http.server_send_url');
|
||||
|
||||
return new FCMSender($client, $url);
|
||||
});
|
||||
}
|
||||
|
||||
protected function provide()
|
||||
public function provides()
|
||||
{
|
||||
return [ 'fcm', 'fcm.client' ];
|
||||
return [ 'fcm.client', 'fcm.group', 'fcm.sender' ];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php namespace LaravelFCM\Facades;
|
||||
|
||||
use LaravelFCM\Message;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class FCM extends Facade {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php namespace LaravelFCM\Facades;
|
||||
|
||||
use LaravelFCM\Message;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class FCMGroup extends Facade {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php namespace LaravelFCM\Message\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
|
||||
/**
|
||||
* Class InvalidOptionsException
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php namespace LaravelFCM\Message\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
|
||||
/**
|
||||
* Class NoTopicProvidedException
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php namespace LaravelFCM\Message;
|
||||
|
||||
use Exception;
|
||||
use LaravelFCM\Message\Exceptions\InvalidOptionsException;
|
||||
use ReflectionClass;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php namespace LaravelFCM\Request;
|
||||
|
||||
use LaravelFCM\Message\Topics;
|
||||
use LaravelFCM\Message\Options;
|
||||
use LaravelFCM\Message\PayloadData;
|
||||
use LaravelFCM\Message\PayloadNotification;
|
||||
use LaravelFCM\Message\Topics;
|
||||
|
||||
/**
|
||||
* Class Request
|
||||
|
||||
@@ -9,7 +9,7 @@ use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
class DownstreamResponse extends BaseResponse {
|
||||
class DownstreamResponse extends BaseResponse implements DownstreamResponseContract{
|
||||
|
||||
const MULTICAST_ID = 'multicast_id';
|
||||
const CANONICAL_IDS = "canonical_ids";
|
||||
|
||||
85
vendor/brozot/laravel-fcm/src/Response/DownstreamResponseContract.php
vendored
Normal file
85
vendor/brozot/laravel-fcm/src/Response/DownstreamResponseContract.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php namespace LaravelFCM\Response;
|
||||
|
||||
/**
|
||||
* Interface DownstreamResponseContract
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
interface DownstreamResponseContract {
|
||||
|
||||
/**
|
||||
* Merge two response
|
||||
*
|
||||
* @param DownstreamResponse $response
|
||||
*/
|
||||
public function merge(DownstreamResponse $response);
|
||||
|
||||
/**
|
||||
* Get the number of device reached with success
|
||||
* @return int
|
||||
*/
|
||||
public function numberSuccess();
|
||||
|
||||
/**
|
||||
* Get the number of device which thrown an error
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberFailure();
|
||||
|
||||
/**
|
||||
* Get the number of device that you need to modify their token
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberModification();
|
||||
|
||||
/**
|
||||
* get token to delete
|
||||
*
|
||||
* remove all tokens returned by this method in your database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensToDelete();
|
||||
|
||||
/**
|
||||
* get token to modify
|
||||
*
|
||||
* key: oldToken
|
||||
* value: new token
|
||||
*
|
||||
* find the old token in your database and replace it with the new one
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensToModify();
|
||||
|
||||
/**
|
||||
* Get tokens that you should resend using exponential backoof
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensToRetry();
|
||||
|
||||
/**
|
||||
* Get tokens that thrown an error
|
||||
*
|
||||
* key : token
|
||||
* value : error
|
||||
*
|
||||
* In production, remove these tokens from you database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensWithError();
|
||||
|
||||
/**
|
||||
* check if missing tokens was given to the request
|
||||
* If true, remove all the empty token in your database
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMissingToken();
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
class GroupResponse extends BaseResponse {
|
||||
class GroupResponse extends BaseResponse implements GroupResponseContract{
|
||||
|
||||
const FAILED_REGISTRATION_IDS = "failed_registration_ids";
|
||||
|
||||
|
||||
30
vendor/brozot/laravel-fcm/src/Response/GroupResponseContract.php
vendored
Normal file
30
vendor/brozot/laravel-fcm/src/Response/GroupResponseContract.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php namespace LaravelFCM\Response;
|
||||
|
||||
/**
|
||||
* Interface GroupResponseContract
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
interface GroupResponseContract {
|
||||
|
||||
/**
|
||||
* Get the number of device reached with success
|
||||
* @return int
|
||||
*/
|
||||
public function numberSuccess();
|
||||
|
||||
/**
|
||||
* Get the number of device which thrown an error
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberFailure();
|
||||
|
||||
/**
|
||||
* Get all token in group that fcm cannot reach
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensFailed();
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php namespace LaravelFCM\Response;
|
||||
|
||||
use LaravelFCM\Message\Topics;
|
||||
use Monolog\Logger;
|
||||
use LaravelFCM\Message\Topics;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
|
||||
@@ -10,7 +10,7 @@ use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
class TopicResponse extends BaseResponse {
|
||||
class TopicResponse extends BaseResponse implements TopicResponseContract{
|
||||
|
||||
const LIMIT_RATE_TOPICS_EXCEEDED = "TopicsMessageRateExceeded";
|
||||
|
||||
|
||||
31
vendor/brozot/laravel-fcm/src/Response/TopicResponseContract.php
vendored
Normal file
31
vendor/brozot/laravel-fcm/src/Response/TopicResponseContract.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php namespace LaravelFCM\Response;
|
||||
|
||||
/**
|
||||
* Interface TopicResponseContract
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
interface TopicResponseContract {
|
||||
|
||||
/**
|
||||
* true if topic sent with success
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess();
|
||||
|
||||
/**
|
||||
* return error message
|
||||
* you should test if it's necessary to resent it
|
||||
*
|
||||
* @return string error
|
||||
*/
|
||||
public function error();
|
||||
|
||||
/**
|
||||
* return true if it's necessary resent it using exponential backoff
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldRetry();
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php namespace LaravelFCM\Sender;
|
||||
|
||||
/**
|
||||
* Class BaseSender
|
||||
*
|
||||
* @package LaravelFCM\Sender
|
||||
*/
|
||||
abstract class BaseSender {
|
||||
|
||||
/**
|
||||
* Guzzle Client
|
||||
* @var \Illuminate\Foundation\Application|mixed
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* configuration
|
||||
* @var array
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* url
|
||||
* @var mixed
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* BaseSender constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = app('fcm.client');
|
||||
$this->config = app('config')->get('fcm.http', []);
|
||||
|
||||
$this->url = $this->getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected abstract function getUrl();
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
*
|
||||
* @package LaravelFCM\Sender
|
||||
*/
|
||||
class FCMGroup extends BaseSender {
|
||||
class FCMGroup extends HTTPSender {
|
||||
|
||||
const CREATE = "create";
|
||||
const ADD = "add";
|
||||
@@ -96,13 +96,4 @@ class FCMGroup extends BaseSender {
|
||||
return $response->getReasonPhrase() != 'OK' || $response->getStatusCode() != 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrl()
|
||||
{
|
||||
return $this->config['server_group_url'];
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,21 @@
|
||||
<?php namespace LaravelFCM\Sender;
|
||||
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use LaravelFCM\FCMRequest;
|
||||
use LaravelFCM\Message\Options;
|
||||
use LaravelFCM\Message\PayloadData;
|
||||
use LaravelFCM\Message\PayloadNotification;
|
||||
use \GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
use LaravelFCM\Message\Topics;
|
||||
use LaravelFCM\Request\Request;
|
||||
use LaravelFCM\Response\DownstreamResponse;
|
||||
use LaravelFCM\Message\Options;
|
||||
use LaravelFCM\Message\PayloadData;
|
||||
use LaravelFCM\Response\GroupResponse;
|
||||
use LaravelFCM\Response\TopicResponse;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use LaravelFCM\Response\DownstreamResponse;
|
||||
use LaravelFCM\Message\PayloadNotification;
|
||||
|
||||
/**
|
||||
* Class FCMSender
|
||||
*
|
||||
* @package LaravelFCM\Sender
|
||||
*/
|
||||
class FCMSender extends BaseSender {
|
||||
class FCMSender extends HTTPSender {
|
||||
|
||||
const MAX_TOKEN_PER_REQUEST = 1000;
|
||||
|
||||
@@ -39,17 +37,13 @@ class FCMSender extends BaseSender {
|
||||
{
|
||||
$response = null;
|
||||
|
||||
if (is_array($to)) {
|
||||
if (is_array($to) && !empty($to)) {
|
||||
|
||||
$partialTokens = array_chunk($to, self::MAX_TOKEN_PER_REQUEST, false);
|
||||
foreach ($partialTokens as $tokens) {
|
||||
$request = new Request($tokens, $options, $notification, $data);
|
||||
|
||||
try {
|
||||
$responseGuzzle = $this->client->post($this->url, $request->build());
|
||||
}
|
||||
catch (ClientException $e) {
|
||||
$responseGuzzle = $e->getResponse();
|
||||
}
|
||||
|
||||
$responseGuzzle = $this->post($request);
|
||||
|
||||
$responsePartial = new DownstreamResponse($responseGuzzle, $tokens);
|
||||
if (!$response) {
|
||||
@@ -62,8 +56,9 @@ class FCMSender extends BaseSender {
|
||||
}
|
||||
else {
|
||||
$request = new Request($to, $options, $notification, $data);
|
||||
$response = $this->client->post($this->url, $request->build());
|
||||
$response = new DownstreamResponse($response, $to);
|
||||
$responseGuzzle = $this->post($request);
|
||||
|
||||
$response = new DownstreamResponse($responseGuzzle, $to);
|
||||
}
|
||||
|
||||
return $response;
|
||||
@@ -83,14 +78,9 @@ class FCMSender extends BaseSender {
|
||||
{
|
||||
$request = new Request($notificationKey, $options, $notification, $data);
|
||||
|
||||
try {
|
||||
$response = $this->client->post($this->url, $request->build());
|
||||
}
|
||||
catch (ClientException $e) {
|
||||
$response = $e->getResponse();
|
||||
}
|
||||
$responseGuzzle = $this->post($request);
|
||||
|
||||
return new GroupResponse($response, $notificationKey);
|
||||
return new GroupResponse($responseGuzzle, $notificationKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,27 +95,29 @@ class FCMSender extends BaseSender {
|
||||
*/
|
||||
public function sendToTopic(Topics $topics, Options $options = null, PayloadNotification $notification = null, PayloadData $data = null)
|
||||
{
|
||||
|
||||
$request = new Request(null, $options, $notification, $data, $topics);
|
||||
try {
|
||||
$response = $this->client->post($this->url, $request->build());
|
||||
}
|
||||
catch (ClientException $e) {
|
||||
$response = $e->getResponse();
|
||||
}
|
||||
|
||||
$responseGuzzle = $this->post($request);
|
||||
|
||||
return new TopicResponse($response, $topics);
|
||||
return new TopicResponse($responseGuzzle, $topics);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the url
|
||||
* @internal
|
||||
*
|
||||
* @return string
|
||||
* @param $request
|
||||
*
|
||||
* @return null|\Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
protected function getUrl()
|
||||
private function post($request)
|
||||
{
|
||||
return $this->config[ 'server_send_url' ];
|
||||
try {
|
||||
$responseGuzzle = $this->client->post($this->url, $request->build());
|
||||
}
|
||||
catch (ClientException $e) {
|
||||
$responseGuzzle = $e->getResponse();
|
||||
}
|
||||
|
||||
return $responseGuzzle;
|
||||
}
|
||||
}
|
||||
38
vendor/brozot/laravel-fcm/src/Sender/HTTPSender.php
vendored
Normal file
38
vendor/brozot/laravel-fcm/src/Sender/HTTPSender.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php namespace LaravelFCM\Sender;
|
||||
|
||||
use GuzzleHttp\ClientInterface;
|
||||
|
||||
/**
|
||||
* Class BaseSender
|
||||
*
|
||||
* @package LaravelFCM\Sender
|
||||
*/
|
||||
abstract class HTTPSender {
|
||||
|
||||
/**
|
||||
* The client used to send messages.
|
||||
*
|
||||
* @var GuzzleHttp\ClientInterface
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* The URL entry point.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Initializes a new sender object.
|
||||
*
|
||||
* @param GuzzleHttp\ClientInterface $client
|
||||
* @param string $url
|
||||
*/
|
||||
public function __construct(ClientInterface $client, $url)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,13 +23,10 @@ class ResponseTest extends FCMTestCase {
|
||||
|
||||
$client = Mockery::mock(Client::class);
|
||||
$client->shouldReceive('post')->once()->andReturn($response);
|
||||
$this->app->singleton('fcm.client', function($app) use($client) {
|
||||
return $client;
|
||||
});
|
||||
|
||||
$tokens = 'uniqueToken';
|
||||
|
||||
$fcm = new FCMSender();
|
||||
$fcm = new FCMSender($client, 'http://test.test');
|
||||
$fcm->sendTo($tokens);
|
||||
}
|
||||
|
||||
@@ -56,16 +53,41 @@ class ResponseTest extends FCMTestCase {
|
||||
|
||||
$client = Mockery::mock(Client::class);
|
||||
$client->shouldReceive('post')->times(10)->andReturn($response);
|
||||
$this->app->singleton('fcm.client', function($app) use($client) {
|
||||
return $client;
|
||||
});
|
||||
|
||||
$tokens = [];
|
||||
for ($i=0 ; $i<10000 ; $i++) {
|
||||
$tokens[$i] = 'token_'.$i;
|
||||
}
|
||||
|
||||
$fcm = new FCMSender();
|
||||
$fcm = new FCMSender($client, 'http://test.test');
|
||||
$fcm->sendTo($tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function an_empty_array_of_tokens_thrown_an_exception()
|
||||
{
|
||||
$response = new Response(400, [], '{
|
||||
"multicast_id": 216,
|
||||
"success": 3,
|
||||
"failure": 3,
|
||||
"canonical_ids": 1,
|
||||
"results": [
|
||||
{ "message_id": "1:0408" },
|
||||
{ "error": "Unavailable" },
|
||||
{ "error": "InvalidRegistration" },
|
||||
{ "message_id": "1:1516" },
|
||||
{ "message_id": "1:2342", "registration_id": "32" },
|
||||
{ "error": "NotRegistered"}
|
||||
]
|
||||
}' );
|
||||
|
||||
$client = Mockery::mock(Client::class);
|
||||
$client->shouldReceive('post')->once()->andReturn($response);
|
||||
|
||||
$fcm = new FCMSender($client, 'http://test.test');
|
||||
$this->setExpectedException(\LaravelFCM\Response\Exceptions\InvalidRequestException::class);
|
||||
$fcm->sendTo([]);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase;
|
||||
|
||||
abstract class FCMTestCase extends Illuminate\Foundation\Testing\TestCase {
|
||||
abstract class FCMTestCase extends TestCase {
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';
|
||||
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$app->register(LaravelFCM\FCMServiceProvider::class);
|
||||
|
||||
$app['config']['fcm.driver'] = 'http';
|
||||
$app['config']['fcm.http.timeout'] = 20;
|
||||
$app['config']['fcm.http.server_send_url'] = 'http://test.test';
|
||||
@@ -16,4 +19,5 @@ abstract class FCMTestCase extends Illuminate\Foundation\Testing\TestCase {
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ class GroupResponseTest extends FCMTestCase {
|
||||
*/
|
||||
public function it_construct_a_response_with_successes()
|
||||
{
|
||||
|
||||
$notificationKey = "notificationKey";
|
||||
|
||||
$response = new \GuzzleHttp\Psr7\Response(200, [], '{
|
||||
@@ -29,7 +28,6 @@ class GroupResponseTest extends FCMTestCase {
|
||||
*/
|
||||
public function it_construct_a_response_with_failures()
|
||||
{
|
||||
|
||||
$notificationKey = "notificationKey";
|
||||
|
||||
$response = new \GuzzleHttp\Psr7\Response(200, [], '{
|
||||
@@ -55,7 +53,6 @@ class GroupResponseTest extends FCMTestCase {
|
||||
*/
|
||||
public function it_construct_a_response_with_partials_failures()
|
||||
{
|
||||
|
||||
$notificationKey = "notificationKey";
|
||||
|
||||
$response = new \GuzzleHttp\Psr7\Response(200, [], '{
|
||||
|
||||
14
vendor/brozot/laravel-fcm/tests/TopicsTest.php
vendored
14
vendor/brozot/laravel-fcm/tests/TopicsTest.php
vendored
@@ -17,7 +17,6 @@ class TopicsTest extends FCMTestCase {
|
||||
|
||||
$this->setExpectedException(NoTopicProvidedException::class);
|
||||
$topics->build();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +31,6 @@ class TopicsTest extends FCMTestCase {
|
||||
$topics->topic('myTopic');
|
||||
|
||||
$this->assertEquals($target, $topics->build());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,12 +113,8 @@ class TopicsTest extends FCMTestCase {
|
||||
|
||||
$client = Mockery::mock(Client::class);
|
||||
$client->shouldReceive('post')->once()->andReturn($response);
|
||||
$this->app->singleton('fcm.client', function($app) use($client) {
|
||||
return $client;
|
||||
});
|
||||
|
||||
|
||||
$fcm = new FCMSender();
|
||||
$fcm = new FCMSender($client, 'http://test.test');
|
||||
|
||||
$topics = new Topics();
|
||||
$topics->topic('test');
|
||||
@@ -141,12 +135,8 @@ class TopicsTest extends FCMTestCase {
|
||||
|
||||
$client = Mockery::mock(Client::class);
|
||||
$client->shouldReceive('post')->once()->andReturn($response);
|
||||
$this->app->singleton('fcm.client', function($app) use($client) {
|
||||
return $client;
|
||||
});
|
||||
|
||||
|
||||
$fcm = new FCMSender();
|
||||
$fcm = new FCMSender($client, 'http://test.test');
|
||||
|
||||
$topics = new Topics();
|
||||
$topics->topic('test');
|
||||
|
||||
223
vendor/brozot/laravel-fcm/tests/mocks/MockDownstreamResponse.php
vendored
Normal file
223
vendor/brozot/laravel-fcm/tests/mocks/MockDownstreamResponse.php
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php namespace LaravelFCM\Mocks;
|
||||
|
||||
use LaravelFCM\Response\DownstreamResponse;
|
||||
use LaravelFCM\Response\DownstreamResponseContract;
|
||||
|
||||
/**
|
||||
* Class MockDownstreamResponse **Only use it for testing**
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
class MockDownstreamResponse implements DownstreamResponseContract {
|
||||
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $numberTokensSuccess = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $messageId;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tokensToDelete = [];
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected $tokensToModify = [];
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected $tokensToRetry = [];
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tokensWithError = [];
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasMissingToken = false;
|
||||
|
||||
/**
|
||||
* DownstreamResponse constructor.
|
||||
*
|
||||
* @param $numberSuccess
|
||||
*/
|
||||
public function __construct($numberSuccess)
|
||||
{
|
||||
$this->numberTokensSuccess = $numberSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not using it
|
||||
*
|
||||
* @param DownstreamResponse $response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function merge(DownstreamResponse $response)
|
||||
{
|
||||
throw new \Exception('You cannot use this method for mocking response');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of device reached with success + numberTokenToModify
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberSuccess()
|
||||
{
|
||||
return $this->numberTokensSuccess + count($this->tokensToModify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of device which thrown an error
|
||||
*
|
||||
* @return int
|
||||
*/public function numberFailure()
|
||||
{
|
||||
return count($this->tokensToDelete()) + count($this->tokensWithError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of device that you need to modify their token
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberModification()
|
||||
{
|
||||
return count($this->tokensToModify());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a token to delete
|
||||
*
|
||||
* @param $token
|
||||
*/
|
||||
public function addTokenToDelete($token)
|
||||
{
|
||||
$this->tokensToDelete[] = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* get token to delete
|
||||
* remove all tokens returned by this method in your database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensToDelete()
|
||||
{
|
||||
return $this->tokensToDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a token to modify
|
||||
*
|
||||
* @param $oldToken
|
||||
* @param $newToken
|
||||
*/
|
||||
public function addTokenToModify($oldToken, $newToken)
|
||||
{
|
||||
$this->tokensToModify[$oldToken] = $newToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* get token to modify
|
||||
* key: oldToken
|
||||
* value: new token
|
||||
* find the old token in your database and replace it with the new one
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensToModify()
|
||||
{
|
||||
return $this->tokensToModify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a token to retry
|
||||
*
|
||||
* @param $token
|
||||
*/
|
||||
public function addTokenToRetry($token)
|
||||
{
|
||||
$this->tokensToRetry[] = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tokens that you should resend using exponential backoof
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensToRetry()
|
||||
{
|
||||
return $this->tokensToRetry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a token to errors
|
||||
*
|
||||
* @param $token
|
||||
* @param $message
|
||||
*/
|
||||
public function addTokenWithError($token, $message)
|
||||
{
|
||||
$this->tokensWithError[$token] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tokens that thrown an error
|
||||
* key : token
|
||||
* value : error
|
||||
* In production, remove these tokens from you database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensWithError()
|
||||
{
|
||||
return $this->tokensWithError;
|
||||
}
|
||||
|
||||
/**
|
||||
* change missing token state
|
||||
* @param $hasMissingToken
|
||||
*/
|
||||
public function setMissingToken($hasMissingToken)
|
||||
{
|
||||
$this->hasMissingToken = $hasMissingToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if missing tokens was given to the request
|
||||
* If true, remove all the empty token in your database
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMissingToken()
|
||||
{
|
||||
return $this->hasMissingToken;
|
||||
}
|
||||
}
|
||||
88
vendor/brozot/laravel-fcm/tests/mocks/MockGroupResponse.php
vendored
Normal file
88
vendor/brozot/laravel-fcm/tests/mocks/MockGroupResponse.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php namespace LaravelFCM\Mocks;
|
||||
|
||||
use LaravelFCM\Response\GroupResponseContract;
|
||||
|
||||
/**
|
||||
* Class MockGroupResponse **Only use it for testing**
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
class MockGroupResponse implements GroupResponseContract {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var int
|
||||
*/
|
||||
protected $numberTokensSuccess = 0;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var int
|
||||
*/
|
||||
protected $numberTokensFailure = 0;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var array
|
||||
*/
|
||||
protected $tokensFailed = [];
|
||||
|
||||
/**
|
||||
* set number of success
|
||||
* @param $numberSuccess
|
||||
*/
|
||||
public function setNumberSuccess($numberSuccess)
|
||||
{
|
||||
$this->numberTokensSuccess = $numberSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of device reached with success
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberSuccess()
|
||||
{
|
||||
return $this->numberTokensSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* set number of failures
|
||||
*
|
||||
* @param $numberFailures
|
||||
*/
|
||||
public function setNumberFailure($numberFailures)
|
||||
{
|
||||
$this->numberTokensSuccess = $numberFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of device which thrown an error
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function numberFailure()
|
||||
{
|
||||
return $this->numberTokensFailure;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a token to the failed list
|
||||
*
|
||||
* @param $tokenFailed
|
||||
*/
|
||||
public function addTokenFailed($tokenFailed)
|
||||
{
|
||||
$this->tokensFailed[] = $tokenFailed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all token in group that fcm cannot reach
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tokensFailed()
|
||||
{
|
||||
return $this->tokensFailed;
|
||||
}
|
||||
}
|
||||
86
vendor/brozot/laravel-fcm/tests/mocks/MockTopicResponse.php
vendored
Normal file
86
vendor/brozot/laravel-fcm/tests/mocks/MockTopicResponse.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php namespace LaravelFCM\Mocks;
|
||||
|
||||
use LaravelFCM\Response\TopicResponseContract;
|
||||
|
||||
/**
|
||||
* Class MockTopicResponse **Only use it for testing**
|
||||
*
|
||||
* @package LaravelFCM\Response
|
||||
*/
|
||||
class MockTopicResponse implements TopicResponseContract {
|
||||
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var string
|
||||
*/
|
||||
protected $topic;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var string
|
||||
*/
|
||||
protected $messageId;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var string
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var bool
|
||||
*/
|
||||
protected $needRetry = false;
|
||||
|
||||
/**
|
||||
* if success set a message id
|
||||
*
|
||||
* @param $messageId
|
||||
*/
|
||||
public function setSuccess($messageId)
|
||||
{
|
||||
$this->messageId = $messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* true if topic sent with success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return (bool) $this->messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* set error
|
||||
* @param $error
|
||||
*/
|
||||
public function setError($error)
|
||||
{
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* return error message
|
||||
* you should test if it's necessary to resent it
|
||||
*
|
||||
* @return string error
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
$this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if it's necessary resent it using exponential backoff
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldRetry()
|
||||
{
|
||||
$this->error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user