laravel-6 support
This commit is contained in:
150
vendor/sly/notification-pusher/doc/apns-adapter.md
vendored
150
vendor/sly/notification-pusher/doc/apns-adapter.md
vendored
@@ -1,150 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## APNS adapter
|
||||
|
||||
[APNS](http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html) adapter is used to push notification to Apple devices.
|
||||
|
||||
### Basic notification push example
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
use Sly\NotificationPusher\PushManager,
|
||||
Sly\NotificationPusher\Adapter\Apns as ApnsAdapter,
|
||||
Sly\NotificationPusher\Collection\DeviceCollection,
|
||||
Sly\NotificationPusher\Model\Device,
|
||||
Sly\NotificationPusher\Model\Message,
|
||||
Sly\NotificationPusher\Model\Push
|
||||
;
|
||||
|
||||
// First, instantiate the manager.
|
||||
//
|
||||
// Example for production environment:
|
||||
// $pushManager = new PushManager(PushManager::ENVIRONMENT_PROD);
|
||||
//
|
||||
// Development one by default (without argument).
|
||||
$pushManager = new PushManager(PushManager::ENVIRONMENT_DEV);
|
||||
|
||||
// Then declare an adapter.
|
||||
$apnsAdapter = new ApnsAdapter(array(
|
||||
'certificate' => '/path/to/your/apns-certificate.pem',
|
||||
));
|
||||
|
||||
// Set the device(s) to push the notification to.
|
||||
$devices = new DeviceCollection(array(
|
||||
new Device('Token1'),
|
||||
// ...
|
||||
));
|
||||
|
||||
// Then, create the push skel.
|
||||
$message = new Message('This is a basic example of push.');
|
||||
|
||||
// Finally, create and add the push to the manager, and push it!
|
||||
$push = new Push($apnsAdapter, $devices, $message);
|
||||
$pushManager->add($push);
|
||||
$pushManager->push();
|
||||
|
||||
foreach($push->getResponses() as $token => $response) {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Custom notification push example
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
use Sly\NotificationPusher\PushManager,
|
||||
Sly\NotificationPusher\Adapter\Apns as ApnsAdapter,
|
||||
Sly\NotificationPusher\Collection\DeviceCollection,
|
||||
Sly\NotificationPusher\Model\Device,
|
||||
Sly\NotificationPusher\Model\Message,
|
||||
Sly\NotificationPusher\Model\Push
|
||||
;
|
||||
|
||||
// First, instantiate the manager.
|
||||
//
|
||||
// Example for production environment:
|
||||
// $pushManager = new PushManager(PushManager::ENVIRONMENT_PROD);
|
||||
//
|
||||
// Development one by default (without argument).
|
||||
$pushManager = new PushManager(PushManager::ENVIRONMENT_DEV);
|
||||
|
||||
// Then declare an adapter.
|
||||
$apnsAdapter = new ApnsAdapter(array(
|
||||
'certificate' => '/path/to/your/apns-certificate.pem',
|
||||
'passPhrase' => 'example',
|
||||
));
|
||||
|
||||
// Set the device(s) to push the notification to.
|
||||
$devices = new DeviceCollection(array(
|
||||
new Device('Token1', array('badge' => 5)),
|
||||
new Device('Token2', array('badge' => 1)),
|
||||
new Device('Token3'),
|
||||
));
|
||||
|
||||
// Then, create the push skel.
|
||||
$message = new Message('This is an example.', array(
|
||||
'badge' => 1,
|
||||
'sound' => 'example.aiff',
|
||||
|
||||
'actionLocKey' => 'Action button title!',
|
||||
'locKey' => 'localized key',
|
||||
'locArgs' => array(
|
||||
'localized args',
|
||||
'localized args',
|
||||
'localized args'
|
||||
),
|
||||
'launchImage' => 'image.jpg',
|
||||
|
||||
'custom' => array('custom data' => array(
|
||||
'we' => 'want', 'send to app'
|
||||
))
|
||||
));
|
||||
|
||||
// Finally, create and add the push to the manager, and push it!
|
||||
$push = new Push($apnsAdapter, $devices, $message);
|
||||
$pushManager->add($push);
|
||||
$pushManager->push(); // Returns a collection of notified devices
|
||||
```
|
||||
|
||||
### Feedback example
|
||||
|
||||
The feedback service is used to list tokens of devices which not have your application anymore.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
use Sly\NotificationPusher\PushManager,
|
||||
Sly\NotificationPusher\Adapter\Apns as ApnsAdapter
|
||||
;
|
||||
|
||||
// First, instantiate the manager.
|
||||
//
|
||||
// Example for production environment:
|
||||
// $pushManager = new PushManager(PushManager::ENVIRONMENT_PROD);
|
||||
//
|
||||
// Development one by default (without argument).
|
||||
$pushManager = new PushManager(PushManager::ENVIRONMENT_DEV);
|
||||
|
||||
// Then declare an adapter.
|
||||
$apnsAdapter = new ApnsAdapter(array(
|
||||
'certificate' => '/path/to/your/apns-certificate.pem',
|
||||
));
|
||||
|
||||
$feedback = $pushManager->getFeedback($apnsAdapter); // Returns an array of Token + DateTime couples
|
||||
```
|
||||
|
||||
* [Installation](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/installation.md)
|
||||
* [Getting started](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/getting-started.md)
|
||||
* APNS adapter
|
||||
* [GCM (FCM) adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md)
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
@@ -1,23 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Create an adapter
|
||||
|
||||
To create your own adapter, just create a class with taking care to extends `\Sly\NotificationPusher\Adapter\BaseAdapter`,
|
||||
which implicitly implements `\Sly\NotificationPusher\Adapter\AdapterInterface` which contains some required methods:
|
||||
|
||||
* `push`: contains the adapter logic to push notifications
|
||||
* `supports`: return the token condition for using the adapter
|
||||
* `getDefaultParameters`: returns default parameters used by the adapter
|
||||
* `getRequiredParameters`: returns required parameters used by the adapter
|
||||
|
||||
Feel free to observe [existent adapters](https://github.com/Ph3nol/NotificationPusher/tree/master/src/Sly/NotificationPusher/Adapter) for concrete example.
|
||||
|
||||
## Documentation index
|
||||
|
||||
* [Installation](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/installation.md)
|
||||
* [Getting started](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/getting-started.md)
|
||||
* [APNS adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/apns-adapter.md)
|
||||
* [GCM (FCM) adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md)
|
||||
* Create an adapter
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
105
vendor/sly/notification-pusher/doc/facades.md
vendored
105
vendor/sly/notification-pusher/doc/facades.md
vendored
@@ -1,105 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Facades
|
||||
|
||||
In order to simplify lib usage some service facades were added.
|
||||
They would return Response object with all information about sent pushes.
|
||||
Also, facades provide useful methods to filter successful and invalid tokens from responses.
|
||||
|
||||
## Basic usage example
|
||||
|
||||
### The Response
|
||||
|
||||
``` php
|
||||
$response->getParsedResponses();
|
||||
$response->getOriginalResponses();
|
||||
$response->getPushCollection();
|
||||
```
|
||||
|
||||
### Android facade
|
||||
|
||||
``` php
|
||||
$android_api_key = 'key';
|
||||
|
||||
//get tokens list from your service
|
||||
$tokensA = ['token1', 'token2'];
|
||||
|
||||
//get messages
|
||||
$messages = [
|
||||
'hi Luc, it\'s test',
|
||||
'test noty 2',
|
||||
];
|
||||
|
||||
//maybe you want some params
|
||||
$params = [];
|
||||
|
||||
//init android facade service
|
||||
$pushNotificationService = new GcmPushService(
|
||||
$android_api_key, PushManager::ENVIRONMENT_PROD
|
||||
);
|
||||
|
||||
//push! you will get a Response with parsed and original response collections
|
||||
//and with a push collection
|
||||
$response = $pushNotificationService->push($tokensA, $messages, $params);
|
||||
|
||||
NOTE: if you need to pass not only data, but also notification array
|
||||
use key notificationData in params, like $params[notificationData] = []
|
||||
OR you could use optional GcmMessage class instead of Message and
|
||||
use it's setter setNotificationData()
|
||||
|
||||
//easily access list of successful and invalid tokens
|
||||
$invalidTokens = $pushNotificationService->getInvalidTokens();
|
||||
$successfulTokens = $pushNotificationService->getSuccessfulTokens();
|
||||
|
||||
die(dump($response, $invalidTokens, $successfulTokens));
|
||||
```
|
||||
|
||||
### APNS facade
|
||||
|
||||
``` php
|
||||
$certificatePath = 'cert.pem';
|
||||
$passPhrase = '';
|
||||
|
||||
//get tokens list
|
||||
$tokensA = ['token1', 'token2'];
|
||||
|
||||
//get messages
|
||||
$messages = [
|
||||
'hi Luc, it\'s test',
|
||||
'test noty 2',
|
||||
];
|
||||
|
||||
//maybe you want some params
|
||||
$params = [];
|
||||
|
||||
//init android facade service
|
||||
$pushNotificationService = new ApnsPushService(
|
||||
$certificatePath, $passPhrase, PushManager::ENVIRONMENT_PROD
|
||||
);
|
||||
|
||||
//push! you will get a Response with parsed and original response collections
|
||||
//and with a push collection
|
||||
$response = $pushNotificationService->push($tokensA, $messages, $params);
|
||||
|
||||
//you could get a feedback with list of successful tokens
|
||||
$feedback = $pushNotificationService->feedback();
|
||||
|
||||
//or!
|
||||
|
||||
//easily access list of successful and invalid tokens
|
||||
//WARNING! these methods would send feedback request anyway
|
||||
$invalidTokens = $pushNotificationService->getInvalidTokens();
|
||||
$successfulTokens = $pushNotificationService->getSuccessfulTokens();
|
||||
|
||||
die(dump($response, $feedback, $invalidTokens, $successfulTokens));
|
||||
```
|
||||
|
||||
## Documentation index
|
||||
|
||||
* [Installation](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/installation.md)
|
||||
* [Getting started](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/getting-started.md)
|
||||
* [APNS adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/apns-adapter.md)
|
||||
* [GCM (FCM) adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md)
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
* Facades
|
||||
@@ -1,84 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## GCM (FCM) adapter
|
||||
|
||||
[GCM](http://developer.android.com/google/gcm/gs.html) adapter is used to push notification to Google/Android devices.
|
||||
[FCM](https://firebase.google.com/docs/cloud-messaging/) is supported. Please see [this comment](https://github.com/Ph3nol/NotificationPusher/pull/141#issuecomment-318896948) for explanation.
|
||||
|
||||
##### Important
|
||||
Parameter `notificatinData` is mandatory for sending messagev via FCM.
|
||||
|
||||
### Custom notification push example
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
use Sly\NotificationPusher\PushManager,
|
||||
Sly\NotificationPusher\Adapter\Gcm as GcmAdapter,
|
||||
Sly\NotificationPusher\Collection\DeviceCollection,
|
||||
Sly\NotificationPusher\Model\Device,
|
||||
Sly\NotificationPusher\Model\Message,
|
||||
Sly\NotificationPusher\Model\Push
|
||||
;
|
||||
|
||||
// First, instantiate the manager.
|
||||
//
|
||||
// Example for production environment:
|
||||
// $pushManager = new PushManager(PushManager::ENVIRONMENT_PROD);
|
||||
//
|
||||
// Development one by default (without argument).
|
||||
$pushManager = new PushManager(PushManager::ENVIRONMENT_DEV);
|
||||
|
||||
// Then declare an adapter.
|
||||
$gcmAdapter = new GcmAdapter(array(
|
||||
'apiKey' => 'YourApiKey',
|
||||
));
|
||||
|
||||
// Set the device(s) to push the notification to.
|
||||
$devices = new DeviceCollection(array(
|
||||
new Device('Token1'),
|
||||
new Device('Token2'),
|
||||
new Device('Token3'),
|
||||
));
|
||||
|
||||
$params = [];
|
||||
|
||||
NOTE: if you need to pass not only data, but also notification array
|
||||
use key notificationData in params, like $params[notificationData] = []
|
||||
OR you could use optional GcmMessage class instead of Message and
|
||||
use it's setter setNotificationData()
|
||||
|
||||
// Then, create the push skel.
|
||||
$message = new Message('This is an example.', $params);
|
||||
|
||||
// Finally, create and add the push to the manager, and push it!
|
||||
$push = new Push($gcmAdapter, $devices, $message);
|
||||
$pushManager->add($push);
|
||||
$pushManager->push(); // Returns a collection of notified devices
|
||||
|
||||
// each response will contain also
|
||||
// the data of the overall delivery
|
||||
foreach($push->getResponses() as $token => $response) {
|
||||
// > $response
|
||||
// Array
|
||||
// (
|
||||
// [message_id] => fake_message_id
|
||||
// [multicast_id] => -1
|
||||
// [success] => 1
|
||||
// [failure] => 0
|
||||
// [canonical_ids] => 0
|
||||
// )
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation index
|
||||
|
||||
* [Installation](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/installation.md)
|
||||
* [Getting started](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/getting-started.md)
|
||||
* [APNS adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/apns-adapter.md)
|
||||
* GCM (FCM) adapter
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
@@ -1,95 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Getting started
|
||||
|
||||
**NOTE** If you want even easier start, please check our facades
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
|
||||
First, we are going to discover this library entities:
|
||||
|
||||
* Models (messages, pushes, devices)
|
||||
* Adapters (APNS, GCM (FCM) etc.)
|
||||
* The Manager
|
||||
|
||||
Here is the basic principle of a notification push:
|
||||
|
||||
A **push** has 3 main elements: a composed **message**, some defined **devices** to notify
|
||||
and an **adapter** matching with these devices.
|
||||
The **manager** has to collect all push notifications and send them.
|
||||
|
||||
Here is how to translate this with code (just a little not-working example):
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
// First, instantiate the manager and declare an adapter.
|
||||
$pushManager = new Sly\NotificationPusher\PushManager();
|
||||
$exampleAdapter = new Sly\NotificationPusher\Adapter\Apns();
|
||||
|
||||
// Set the device(s) to push the notification to.
|
||||
$devices = new Sly\NotificationPusher\Collection\DeviceCollection(array(
|
||||
new Sly\NotificationPusher\Model\Device('Token1'),
|
||||
new Sly\NotificationPusher\Model\Device('Token2'),
|
||||
new Sly\NotificationPusher\Model\Device('Token3'),
|
||||
// ...
|
||||
));
|
||||
|
||||
// Then, create the push skel.
|
||||
$message = new Sly\NotificationPusher\Model\Message('This is an example.');
|
||||
|
||||
// Finally, create and add the push to the manager, and push it!
|
||||
$push = new Sly\NotificationPusher\Model\Push($exampleAdapter, $devices, $message);
|
||||
$pushManager->add($push);
|
||||
$pushManager->push();
|
||||
|
||||
foreach($push->getResponses() as $token => $response) {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## More about the Message entity
|
||||
|
||||
Some general options can be passed to the message entity and be used by adapters.
|
||||
A message pushed from APNS adapter can comport a "badge" or "sound" information which will be set with
|
||||
instance constructor second argument:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
$message = new Sly\NotificationPusher\Model\Message('This is an example.', array(
|
||||
'badge' => 1,
|
||||
'sound' => 'example.aiff',
|
||||
// ...
|
||||
));
|
||||
```
|
||||
|
||||
## More about the Device entity
|
||||
|
||||
The device can comport some dedicated informations that could be used by adapters.
|
||||
For example, APNS adapter could want to know a device badge status for incrementing it with message's one.
|
||||
|
||||
Here is an example of this:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
$message = new Sly\NotificationPusher\Model\Message('This is an example.', array(
|
||||
'badge' => 1,
|
||||
// ...
|
||||
));
|
||||
|
||||
$devices = new Sly\NotificationPusher\Collection\DeviceCollection(array(
|
||||
new Sly\NotificationPusher\Model\Device('Token1', array('badge' => 5)),
|
||||
// ...
|
||||
));
|
||||
```
|
||||
|
||||
## Documentation index
|
||||
|
||||
* [Installation](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/installation.md)
|
||||
* Getting started
|
||||
* [APNS adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/apns-adapter.md)
|
||||
* [GCM (FCM) adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md)
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
@@ -1,17 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Installation
|
||||
|
||||
Use [Composer](http://getcomposer.org) to install this library.
|
||||
|
||||
Run `composer require sly/notification-pusher` to install the latest version.
|
||||
|
||||
## Documentation index
|
||||
|
||||
* Installation
|
||||
* [Getting started](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/getting-started.md)
|
||||
* [APNS adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/apns-adapter.md)
|
||||
* [GCM (FCM) adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md)
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
@@ -1,35 +0,0 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Push from CLI
|
||||
|
||||
For some reasons (tests or others), you could be happened to use pushing from CLI.
|
||||
|
||||
To do this, use `np` script (available at root directory) this way:
|
||||
|
||||
```
|
||||
./np push <adapter> <token-or-registration-id> "Your message" --option1=value1 --option2=value2 ...
|
||||
```
|
||||
|
||||
Each options matches with adapters required and optional ones.
|
||||
|
||||
Here is a concrete APNS adapter example:
|
||||
|
||||
```
|
||||
./np push apns <token> "It's an example!" --certificate=/path/to/the/certificate.pem
|
||||
```
|
||||
|
||||
Here is a concrete GCM adapter example:
|
||||
|
||||
```
|
||||
./np push gcm <token> "It's an example!" --api-key=XXXXXXXXXX
|
||||
```
|
||||
|
||||
## Documentation index
|
||||
|
||||
* [Installation](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/installation.md)
|
||||
* [Getting started](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/getting-started.md)
|
||||
* [APNS adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/apns-adapter.md)
|
||||
* [GCM (FCM) adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md)
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* Push from CLI
|
||||
* [Facades](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/facades.md)
|
||||
Reference in New Issue
Block a user