update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
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'
|
||||
)
|
||||
|
||||
);
|
Reference in New Issue
Block a user