update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
147
vendor/sly/notification-pusher/doc/apns-adapter.md
vendored
Normal file
147
vendor/sly/notification-pusher/doc/apns-adapter.md
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
# 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_PRODUCTION);
|
||||
//
|
||||
// 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();
|
||||
```
|
||||
|
||||
### 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_PRODUCTION);
|
||||
//
|
||||
// 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_PRODUCTION);
|
||||
//
|
||||
// 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
|
||||
```
|
||||
|
||||
## 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
|
||||
* [GCM adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-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)
|
||||
22
vendor/sly/notification-pusher/doc/create-an-adapter.md
vendored
Normal file
22
vendor/sly/notification-pusher/doc/create-an-adapter.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Create an adapter
|
||||
|
||||
To create your own adapter, just create a class with taking care to extends `\Sly\NotificationPusher\Adapter\BaseAdapter`
|
||||
and 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 adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-adapter.md)
|
||||
* Create an adapter
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
58
vendor/sly/notification-pusher/doc/gcm-adapter.md
vendored
Normal file
58
vendor/sly/notification-pusher/doc/gcm-adapter.md
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## GCM adapter
|
||||
|
||||
[GCM](http://developer.android.com/google/gcm/gs.html) adapter is used to push notification to Google/Android devices.
|
||||
|
||||
### 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_PRODUCTION);
|
||||
//
|
||||
// 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'),
|
||||
));
|
||||
|
||||
// Then, create the push skel.
|
||||
$message = new Message('This is an example.');
|
||||
|
||||
// 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
|
||||
```
|
||||
|
||||
## 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 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)
|
||||
87
vendor/sly/notification-pusher/doc/getting-started.md
vendored
Normal file
87
vendor/sly/notification-pusher/doc/getting-started.md
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Getting started
|
||||
|
||||
First, we are going to discover this library entities:
|
||||
|
||||
* Models (messages, pushes, devices)
|
||||
* Adapters (APNS, GCM 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 PushManager();
|
||||
$exampleAdapter = new ApnsAdapter();
|
||||
|
||||
// Set the device(s) to push the notification to.
|
||||
$devices = new DeviceCollection(array(
|
||||
new Device('Token1'),
|
||||
new Device('Token2'),
|
||||
new Device('Token3'),
|
||||
// ...
|
||||
));
|
||||
|
||||
// Then, create the push skel.
|
||||
$message = new Message('This is an example.');
|
||||
|
||||
// Finally, create and add the push to the manager, and push it!
|
||||
$push = new Push($exampleAdapter, $devices, $message);
|
||||
$pushManager->add($push);
|
||||
$pushManager->push();
|
||||
```
|
||||
|
||||
## 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 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 Message('This is an example.', array(
|
||||
'badge' => 1,
|
||||
// ...
|
||||
));
|
||||
|
||||
$devices = new DeviceCollection(array(
|
||||
new 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 adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-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)
|
||||
23
vendor/sly/notification-pusher/doc/installation.md
vendored
Normal file
23
vendor/sly/notification-pusher/doc/installation.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# NotificationPusher - Documentation
|
||||
|
||||
## Installation
|
||||
|
||||
Use [Composer](http://getcomposer.org) to install this library.
|
||||
|
||||
Into your `composer.json` file, just include this library with adding:
|
||||
|
||||
```
|
||||
"sly/notification-pusher": "2.x"
|
||||
```
|
||||
|
||||
Then, run `composer update sly/notification-pusher` and enjoy.
|
||||
|
||||
## 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 adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-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)
|
||||
* [Push from CLI](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/push-from-cli.md)
|
||||
34
vendor/sly/notification-pusher/doc/push-from-cli.md
vendored
Normal file
34
vendor/sly/notification-pusher/doc/push-from-cli.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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 adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-adapter.md)
|
||||
* [Create an adapter](https://github.com/Ph3nol/NotificationPusher/blob/master/doc/create-an-adapter.md)
|
||||
* Push from CLI
|
||||
Reference in New Issue
Block a user