update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
4
vendor/davibennun/laravel-push-notification/.gitignore
vendored
Normal file
4
vendor/davibennun/laravel-push-notification/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/vendor
|
||||
composer.phar
|
||||
composer.lock
|
||||
.DS_Store
|
12
vendor/davibennun/laravel-push-notification/.travis.yml
vendored
Normal file
12
vendor/davibennun/laravel-push-notification/.travis.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
||||
before_script:
|
||||
- curl -s http://getcomposer.org/installer | php
|
||||
- php composer.phar install --dev
|
||||
|
||||
script: phpunit
|
132
vendor/davibennun/laravel-push-notification/README.md
vendored
Normal file
132
vendor/davibennun/laravel-push-notification/README.md
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
Laravel Push Notification
|
||||
=========
|
||||
|
||||
Package to enable sending push notifications to devices
|
||||
|
||||
Installation
|
||||
----
|
||||
|
||||
Update your `composer.json` file to include this package as a dependency
|
||||
|
||||
Laravel 5
|
||||
|
||||
```json
|
||||
"davibennun/laravel-push-notification": "dev-laravel5"
|
||||
```
|
||||
Laravel 4.*
|
||||
```json
|
||||
"davibennun/laravel-push-notification": "dev-master"
|
||||
```
|
||||
|
||||
Register the PushNotification service provider by adding it to the providers array.
|
||||
```php
|
||||
'providers' => array(
|
||||
...
|
||||
'Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider'
|
||||
)
|
||||
```
|
||||
|
||||
Alias the PushNotification facade by adding it to the aliases array in the `app/config/app.php` file.
|
||||
```php
|
||||
'aliases' => array(
|
||||
...
|
||||
'PushNotification' => 'Davibennun\LaravelPushNotification\Facades\PushNotification'
|
||||
)
|
||||
```
|
||||
|
||||
# Configuration
|
||||
|
||||
Copy the config file into your project by running
|
||||
|
||||
Laravel 5
|
||||
```php
|
||||
php artisan vendor:publish --provider="Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider" --tag="config"
|
||||
```
|
||||
|
||||
Laravel 4.*
|
||||
```
|
||||
php artisan vendor:publish --provider="Vendor/Davibennun/LaravelPushNotification/LaravelPushNotificationServiceProvider" --tag="config"
|
||||
```
|
||||
|
||||
This will generate a config file like this
|
||||
```php
|
||||
array(
|
||||
'appNameIOS'=>array(
|
||||
'environment' => 'development',
|
||||
'certificate' => '/path/to/certificate.pem',
|
||||
'passPhrase' => 'password',
|
||||
'service' => 'apns'
|
||||
),
|
||||
'appNameAndroid'=>array(
|
||||
'environment' => 'production',
|
||||
'apiKey' => 'yourAPIKey',
|
||||
'service' => 'gcm'
|
||||
)
|
||||
);
|
||||
```
|
||||
Where all first level keys corresponds to an service configuration, each service has its own properties, android for instance have `apiKey` and IOS uses `certificate` and `passPhrase`. You can set as many services configurations as you want, one for each app.
|
||||
|
||||
##### Dont forget to set `service` key to identify IOS `'service'=>'apns'` and Android `'service'=>'gcm'`
|
||||
|
||||
##### The certificate path must be an absolute path, so in the configuration file you can use these:
|
||||
```
|
||||
//Path to the 'app' folder
|
||||
'certificate'=>app_path().'/myCert.pem'
|
||||
```
|
||||
Laravel functions are also available `public_path()` `storage_path()` `base_path()`
|
||||
|
||||
# Usage
|
||||
```php
|
||||
|
||||
PushNotification::app('appNameIOS')
|
||||
->to($deviceToken)
|
||||
->send('Hello World, i`m a push message');
|
||||
|
||||
```
|
||||
Where app argument `appNameIOS` refers to defined service in config file.
|
||||
To multiple devices and optioned message:
|
||||
```php
|
||||
$devices = PushNotification::DeviceCollection(array(
|
||||
PushNotification::Device('token', array('badge' => 5)),
|
||||
PushNotification::Device('token1', array('badge' => 1)),
|
||||
PushNotification::Device('token2')
|
||||
));
|
||||
$message = PushNotification::Message('Message Text',array(
|
||||
'badge' => 1,
|
||||
'sound' => 'example.aiff',
|
||||
|
||||
'actionLocKey' => 'Action button title!',
|
||||
'locKey' => 'localized key',
|
||||
'locArgs' => array(
|
||||
'localized args',
|
||||
'localized args',
|
||||
),
|
||||
'launchImage' => 'image.jpg',
|
||||
|
||||
'custom' => array('custom data' => array(
|
||||
'we' => 'want', 'send to app'
|
||||
))
|
||||
));
|
||||
|
||||
collection = PushNotification::app('appNameIOS')
|
||||
->to($devices)
|
||||
->send($message);
|
||||
|
||||
// get response for each device push
|
||||
foreach ($collection->pushManager as $push) {
|
||||
$response = $push->getAdapter()->getResponse();
|
||||
}
|
||||
|
||||
// access to adapter for advanced settings
|
||||
$push = PushNotification::app('appNameAndroid');
|
||||
$push->adapter->setAdapterParameters(['sslverifypeer' => false]);
|
||||
```
|
||||
This package is wrapps [Notification Package] and adds some flavor to it.
|
||||
|
||||
#### Usage advice
|
||||
This package should be used with [Laravel Queues], so pushes dont blocks the user and are processed in the background, meaning a better flow.
|
||||
|
||||
|
||||
|
||||
[Notification Package]:https://github.com/Ph3nol/NotificationPusher
|
||||
[Laravel Queues]:http://laravel.com/docs/queues
|
22
vendor/davibennun/laravel-push-notification/composer.json
vendored
Normal file
22
vendor/davibennun/laravel-push-notification/composer.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "davibennun/laravel-push-notification",
|
||||
"description": "Laravel package to send push notifications to mobile devices (apns, gcm)",
|
||||
"keywords": ["apns","gcm","push","notification", "laravel"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "DaviBenNun",
|
||||
"email": "davi@andradenunes.org"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"illuminate/support": "5.*",
|
||||
"sly/notification-pusher": "2.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Davibennun\\LaravelPushNotification": "src/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
18
vendor/davibennun/laravel-push-notification/phpunit.xml
vendored
Normal file
18
vendor/davibennun/laravel-push-notification/phpunit.xml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Package Test Suite">
|
||||
<directory suffix=".php">./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
42
vendor/davibennun/laravel-push-notification/src/Davibennun/LaravelPushNotification/App.php
vendored
Normal file
42
vendor/davibennun/laravel-push-notification/src/Davibennun/LaravelPushNotification/App.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php namespace Davibennun\LaravelPushNotification;
|
||||
|
||||
use Sly\NotificationPusher\PushManager,
|
||||
Sly\NotificationPusher\Model\Device,
|
||||
Sly\NotificationPusher\Model\Message,
|
||||
Sly\NotificationPusher\Model\Push;
|
||||
|
||||
class App {
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->pushManager = new PushManager($config['environment'] == "development" ? PushManager::ENVIRONMENT_DEV : PushManager::ENVIRONMENT_PROD);
|
||||
|
||||
$adapterClassName = 'Sly\\NotificationPusher\\Adapter\\'.ucfirst($config['service']);
|
||||
|
||||
$adapterConfig = $config;
|
||||
unset($adapterConfig['environment'], $adapterConfig['service']);
|
||||
|
||||
$this->adapter = new $adapterClassName($adapterConfig);
|
||||
}
|
||||
|
||||
public function to($addressee)
|
||||
{
|
||||
$this->addressee = is_string($addressee) ? new Device($addressee) : $addressee;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send($message, $options = array()) {
|
||||
$push = new Push($this->adapter, $this->addressee, ($message instanceof Message) ? $message : new Message($message, $options));
|
||||
|
||||
$this->pushManager->add($push);
|
||||
|
||||
$this->pushManager->push();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFeedback() {
|
||||
return $this->pushManager->getFeedback($this->adapter);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php namespace Davibennun\LaravelPushNotification\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class PushNotification extends Facade {
|
||||
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor() { return 'pushNotification'; }
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
<?php namespace Davibennun\LaravelPushNotification;
|
||||
|
||||
use Illuminate\Support\ServiceProvider,
|
||||
Davibennun\LaravelPushNotification\PushNotification;
|
||||
|
||||
class LaravelPushNotificationServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$config_path = function_exists('config_path') ? config_path('push-notification.php') : 'push-notification.php';
|
||||
$this->publishes([
|
||||
__DIR__.'/../../config/config.php' => $config_path
|
||||
], 'config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app['pushNotification'] = $this->app->share(function($app)
|
||||
{
|
||||
return new PushNotification();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php namespace Davibennun\LaravelPushNotification;
|
||||
|
||||
class PushNotification {
|
||||
|
||||
public function app($appName)
|
||||
{
|
||||
$config = is_array($appName) ? $appName : config('push-notification.'.$appName);
|
||||
return new App($config);
|
||||
}
|
||||
|
||||
public function Message()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\Message'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
public function Device()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\Device'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
public function DeviceCollection()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\Collection\DeviceCollection'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
public function PushManager()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\PushManager'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
public function ApnsAdapter()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\Adapter\ApnsAdapter'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
public function GcmAdapter()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\GcmAdapter'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
public function Push()
|
||||
{
|
||||
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\Push'));
|
||||
return $instance->newInstanceArgs(func_get_args());
|
||||
}
|
||||
|
||||
}
|
17
vendor/davibennun/laravel-push-notification/src/config/config.php
vendored
Normal file
17
vendor/davibennun/laravel-push-notification/src/config/config.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
|
||||
'appNameIOS' => array(
|
||||
'environment' =>'development',
|
||||
'certificate' =>'/path/to/certificate.pem',
|
||||
'passPhrase' =>'password',
|
||||
'service' =>'apns'
|
||||
),
|
||||
'appNameAndroid' => array(
|
||||
'environment' =>'production',
|
||||
'apiKey' =>'yourAPIKey',
|
||||
'service' =>'gcm'
|
||||
)
|
||||
|
||||
);
|
0
vendor/davibennun/laravel-push-notification/tests/.gitkeep
vendored
Normal file
0
vendor/davibennun/laravel-push-notification/tests/.gitkeep
vendored
Normal file
Reference in New Issue
Block a user