diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 77e85243d7a9..6d4ef0ccf1e7 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -117,4 +117,77 @@ class AccountApiController extends BaseAPIController return $this->response($account); } + + public function addDeviceToken(Request $request) + { + $account = Auth::user()->account; + + //scan if this user has a token already registered (tokens can change, so we need to use the users email as key) + $devices = json_decode($account->devices,TRUE); + + + for($x=0; $xusername) { + $devices[$x]['token'] = $request->token; //update + $account->devices = json_encode($devices); + $account->save(); + return $this->response($account); + } + } + + //User does not have a device, create new record + + $newDevice = [ + 'token' => $request->token, + 'email' => $request->email, + 'device' => $request->device, + 'notify_sent' => TRUE, + 'notify_viewed' => TRUE, + 'notify_approved' => TRUE, + 'notify_paid' => TRUE, + ]; + + $devices[] = $newDevice; + $account->devices = json_encode($devices); + $account->save(); + + return $this->response($account); + + } + + public function updatePushNotifications(Request $request) + { + $account = Auth::user()->account; + + $devices = json_decode($account->devices, TRUE); + + if(count($devices)<1) + return $this->errorResponse(['message'=>'no devices exist'], 400); + + for($x=0; $xusername) + { + unset($devices[$x]); + + $newDevice = [ + 'token' => $request->token, + 'email' => $request->email, + 'device' => $request->device, + 'notify_sent' => $request->notify_sent, + 'notify_viewed' => $request->notify_viewed, + 'notify_approved' => $request->notify_approved, + 'notify_paid' => $request->notify_paid, + ]; + + $devices[] = $newDevice; + $account->devices = json_encode($devices); + $account->save(); + + return $this->response($account); + } + } + + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 1a9240377010..c00eb8f8e91c 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -235,6 +235,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function() Route::resource('tax_rates', 'TaxRateApiController'); Route::resource('users', 'UserApiController'); Route::resource('expenses','ExpenseApiController'); + Route::post('add_token', 'AccountApiController@addDeviceToken'); + Route::post('update_notifications', 'AccountApiController@updatePushNotifications'); // Vendor Route::resource('vendors', 'VendorApiController'); @@ -552,6 +554,9 @@ if (!defined('CONTACT_EMAIL')) { define('TEST_PASSWORD', 'password'); define('API_SECRET', 'API_SECRET'); + define('IOS_PRODUCTION_PUSH','ninjaIOS'); + define('IOS_DEV_PUSH','devNinjaIOS'); + define('TOKEN_BILLING_DISABLED', 1); define('TOKEN_BILLING_OPT_IN', 2); define('TOKEN_BILLING_OPT_OUT', 3); diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php index aba304457528..c7b58fe30ba5 100644 --- a/app/Listeners/NotificationListener.php +++ b/app/Listeners/NotificationListener.php @@ -9,16 +9,19 @@ use App\Events\InvoiceInvitationWasViewed; use App\Events\QuoteInvitationWasViewed; use App\Events\QuoteInvitationWasApproved; use App\Events\PaymentWasCreated; +use App\Ninja\Notifications; class NotificationListener { protected $userMailer; protected $contactMailer; + protected $pushService; - public function __construct(UserMailer $userMailer, ContactMailer $contactMailer) + public function __construct(UserMailer $userMailer, ContactMailer $contactMailer, Notifications\PushService $pushService) { $this->userMailer = $userMailer; $this->contactMailer = $contactMailer; + $this->pushService = $pushService; } private function sendEmails($invoice, $type, $payment = null) @@ -35,26 +38,31 @@ class NotificationListener public function emailedInvoice(InvoiceWasEmailed $event) { $this->sendEmails($event->invoice, 'sent'); + $this->pushService->sendNotification($event->invoice, 'sent'); } public function emailedQuote(QuoteWasEmailed $event) { $this->sendEmails($event->quote, 'sent'); + $this->pushService->sendNotification($event->quote, 'sent'); } public function viewedInvoice(InvoiceInvitationWasViewed $event) { $this->sendEmails($event->invoice, 'viewed'); + $this->pushService->sendNotification($event->invoice, 'viewed'); } public function viewedQuote(QuoteInvitationWasViewed $event) { $this->sendEmails($event->quote, 'viewed'); + $this->pushService->sendNotification($event->quote, 'viewed'); } public function approvedQuote(QuoteInvitationWasApproved $event) { $this->sendEmails($event->quote, 'approved'); + $this->pushService->sendNotification($event->quote, 'approved'); } public function createdPayment(PaymentWasCreated $event) @@ -66,6 +74,8 @@ class NotificationListener $this->contactMailer->sendPaymentConfirmation($event->payment); $this->sendEmails($event->payment->invoice, 'paid', $event->payment); + + $this->pushService->sendNotification($event->payment->invoice, 'paid'); } } \ No newline at end of file diff --git a/app/Ninja/Notifications/PushFactory.php b/app/Ninja/Notifications/PushFactory.php new file mode 100644 index 000000000000..7f882ff1d0a0 --- /dev/null +++ b/app/Ninja/Notifications/PushFactory.php @@ -0,0 +1,96 @@ +certificate - Development or production. + * + * Static variables defined in routes.php + * + * IOS_PRODUCTION_PUSH + * IOS_DEV_PUSH + */ + + public function __construct() + { + $this->certificate = IOS_DEV_PUSH; + } + + /** + * customMessage function + * + * Send a message with a nested custom payload to perform additional trickery within application + * + * @access public + * + * @param $token + * @param $message + * @param $messageArray + * + * @return void + */ + public function customMessage($token, $message, $messageArray) + { + $customMessage = PushNotification::Message($message, $messageArray); + + $this->message($token, $customMessage); + } + + /** + * message function + * + * Send a plain text only message to a single device. + * + * @access public + * + * @param $token - device token + * @param $message - user specific message + * + * @return void + * + */ + + public function message($token, $message) + { + PushNotification::app($this->certificate) + ->to($token) + ->send($message); + } + + /** + * getFeedback function + * + * Returns an array of expired/invalid tokens to be removed from iOS PUSH notifications. + * + * We need to run this once ~ 24hrs + * + * @access public + * + * @param string $token - A valid token (can be any valid token) + * @param string $message - Nil value for message + * + * @return array + */ + public function getFeedback($token, $message = '') + { + + $feedback = PushNotification::app($this->certificate) + ->to($token) + ->send($message); + + return $feedback->getFeedback(); + } + +} \ No newline at end of file diff --git a/app/Services/PushService.php b/app/Services/PushService.php new file mode 100644 index 000000000000..00591e263323 --- /dev/null +++ b/app/Services/PushService.php @@ -0,0 +1,171 @@ +devices Definition + * + * @param string token (push notification device token) + * @param string email (user email address - required for use as key) + * @param string device (ios, gcm etc etc) + * @param bool notify_sent + * @param bool notify_paid + * @param bool notify_approved + * @param bool notify_viewed + */ + +class PushService +{ + protected $pushFactory; + + /** + * @param PushFactory $pushFactory + */ + public function __construct(PushFactory $pushFactory) + { + $this->pushFactory = $pushFactory; + } + + /** + * @param $invoice - Invoice object + * @param $type - Type of notification, ie. Quote APPROVED, Invoice PAID, Invoice/Quote SENT, Invoice/Quote VIEWED + */ + + public function sendNotification($invoice, $type) + { + //check user has registered for push notifications + if(!$this->checkDeviceExists($invoice->account)) + return; + + //Harvest an array of devices that are registered for this notification type + $devices = json_decode($invoice->account->devices, TRUE); + + foreach($devices as $device) + { + if(($device["notify_{$type}"] == TRUE) && ($device['device'] == 'ios')) + $this->pushMessage($invoice, $device['token'], $device["notify_{$type}"]); + } + + + } + + + /** + * pushMessage function + * + * method to dispatch iOS notifications + * + * @param $invoice + * @param $token + * @param $type + */ + private function pushMessage($invoice, $token, $type) + { + $this->pushFactory->message($token, $this->messageType($invoice, $type)); + } + + + /** + * checkDeviceExists function + * + * Returns a boolean if this account has devices registered for PUSH notifications + * + * @param $account + * @return bool + */ + private function checkDeviceExists($account) + { + $devices = json_decode($account->devices, TRUE); + + if(count($devices) >= 1) + return TRUE; + else + return FALSE; + } + + /** + * messageType function + * + * method which formats an appropriate message depending on message type + * + * @param $invoice + * @param $type + * @return string + */ + private function messageType($invoice, $type) + { + switch($type) + { + case 'notify_sent': + return $this->entitySentMessage($invoice); + break; + + case 'notify_paid': + return $this->invoicePaidMessage($invoice); + break; + + case 'notify_approved': + return $this->quoteApprovedMessage($invoice); + break; + + case 'notify_viewed': + return $this->entityViewedMessage($invoice); + break; + } + } + + /** + * @param $invoice + * @return string + */ + private function entitySentMessage($invoice) + { + if($invoice->is_quote) + return 'Quote #{$invoice->invoice_number} sent!'; + else + return 'Invoice #{$invoice->invoice_number} sent!'; + + } + + /** + * @param $invoice + * @return string + */ + private function invoicePaidMessage($invoice) + { + return 'Invoice #{$invoice->invoice_number} paid!'; + } + + /** + * @param $invoice + * @return string + */ + private function quoteApprovedMessage($invoice) + { + return 'Quote #{$invoice->invoice_number} approved!'; + } + + /** + * @param $invoice + * @return string + */ + private function entityViewedMessage($invoice) + { + if($invoice->is_quote) + return 'Quote #{$invoice->invoice_number} viewed!'; + else + return 'Invoice #{$invoice->invoice_number} viewed!'; + + } + + + +} \ No newline at end of file diff --git a/composer.json b/composer.json index 5d368506f687..599bb86582ff 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ } ], "require": { + "turbo124/laravel-push-notification": "dev-laravel5", "omnipay/mollie": "dev-master#22956c1a62a9662afa5f5d119723b413770ac525", "omnipay/2checkout": "dev-master#e9c079c2dde0d7ba461903b3b7bd5caf6dee1248", "omnipay/gocardless": "dev-master", diff --git a/composer.lock b/composer.lock index b6793fee87ff..01454a6d581e 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "efa524cf528035fe964d10e5064295e2", - "content-hash": "a9e9055b6b694b4cf203004fc4b02f7c", + "hash": "334783c40534b498757994eefba6b9d2", + "content-hash": "be4521507359c58fe19eb34102e78202", "packages": [ { "name": "agmscode/omnipay-agms", @@ -847,6 +847,33 @@ ], "time": "2015-12-15 20:31:39" }, + { + "name": "container-interop/container-interop", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "time": "2014-12-30 15:22:37" + }, { "name": "danielstjules/stringy", "version": "1.10.0", @@ -5957,6 +5984,70 @@ ], "time": "2016-02-22 17:40:00" }, + { + "name": "sly/notification-pusher", + "version": "v2.2.12", + "source": { + "type": "git", + "url": "https://github.com/Ph3nol/NotificationPusher.git", + "reference": "f9a99edb4e26254baf1f7fb1354aa5a3f2c3b0ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ph3nol/NotificationPusher/zipball/f9a99edb4e26254baf1f7fb1354aa5a3f2c3b0ae", + "reference": "f9a99edb4e26254baf1f7fb1354aa5a3f2c3b0ae", + "shasum": "" + }, + "require": { + "doctrine/inflector": "~1.0", + "php": ">=5.5", + "symfony/console": "~2.3", + "symfony/options-resolver": "~2.3", + "symfony/process": "~2.3", + "zendframework/zendservice-apple-apns": "^1.1.0", + "zendframework/zendservice-google-gcm": "1.*" + }, + "require-dev": { + "atoum/atoum": "dev-master" + }, + "bin": [ + "np" + ], + "type": "standalone", + "autoload": { + "psr-0": { + "Sly": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cédric Dugat", + "email": "cedric@dugat.me" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Ph3nol/NotificationPusher/contributors" + } + ], + "description": "Standalone PHP library for easy devices notifications push.", + "homepage": "https://github.com/Ph3nol/NotificationPusher", + "keywords": [ + "android", + "apns", + "apple", + "gcm", + "iphone", + "message", + "notification", + "push", + "pusher" + ], + "time": "2015-10-01 07:56:41" + }, { "name": "softcommerce/omnipay-paytrace", "version": "v1.0.1", @@ -6588,6 +6679,60 @@ "homepage": "https://symfony.com", "time": "2016-02-28 20:37:08" }, + { + "name": "symfony/options-resolver", + "version": "v2.8.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "d1e6e9182d9e5af6367bf85175e708f8b4a828c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/d1e6e9182d9e5af6367bf85175e708f8b4a828c0", + "reference": "d1e6e9182d9e5af6367bf85175e708f8b4a828c0", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "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 OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2016-01-21 09:05:51" + }, { "name": "symfony/polyfill-php56", "version": "v1.1.0", @@ -7034,6 +7179,48 @@ ], "time": "2016-01-07 17:12:58" }, + { + "name": "turbo124/laravel-push-notification", + "version": "dev-laravel5", + "source": { + "type": "git", + "url": "https://github.com/turbo124/laravel-push-notification.git", + "reference": "b703b0fe02719a540139f5d26b73ac53a198b50d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/turbo124/laravel-push-notification/zipball/b703b0fe02719a540139f5d26b73ac53a198b50d", + "reference": "b703b0fe02719a540139f5d26b73ac53a198b50d", + "shasum": "" + }, + "require": { + "illuminate/support": "5.*", + "php": ">=5.3.0", + "sly/notification-pusher": "2.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "Davibennun\\LaravelPushNotification": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "authors": [ + { + "name": "DaviBenNun", + "email": "davi@andradenunes.org" + } + ], + "description": "Laravel package to send push notifications to mobile devices (apns, gcm)", + "keywords": [ + "apns", + "gcm", + "laravel", + "notification", + "push" + ], + "time": "2015-06-15 13:11:17" + }, { "name": "twbs/bootstrap", "version": "v3.3.6", @@ -7305,6 +7492,445 @@ "description": "A Swiftmailer Transport for Postmark.", "time": "2015-11-30 18:23:03" }, + { + "name": "zendframework/zend-escaper", + "version": "2.5.1", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-escaper.git", + "reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73", + "reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Escaper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "homepage": "https://github.com/zendframework/zend-escaper", + "keywords": [ + "escaper", + "zf2" + ], + "time": "2015-06-03 14:05:37" + }, + { + "name": "zendframework/zend-http", + "version": "2.5.4", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-http.git", + "reference": "7b920b4ec34b5ee58f76eb4e8c408b083121953c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-http/zipball/7b920b4ec34b5ee58f76eb4e8c408b083121953c", + "reference": "7b920b4ec34b5ee58f76eb4e8c408b083121953c", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "zendframework/zend-loader": "^2.5", + "zendframework/zend-stdlib": "^2.5 || ^3.0", + "zendframework/zend-uri": "^2.5", + "zendframework/zend-validator": "^2.5" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "^4.0", + "zendframework/zend-config": "^2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Http\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests", + "homepage": "https://github.com/zendframework/zend-http", + "keywords": [ + "http", + "zf2" + ], + "time": "2016-02-04 20:36:48" + }, + { + "name": "zendframework/zend-json", + "version": "2.6.1", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-json.git", + "reference": "4c8705dbe4ad7d7e51b2876c5b9eea0ef916ba28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-json/zipball/4c8705dbe4ad7d7e51b2876c5b9eea0ef916ba28", + "reference": "4c8705dbe4ad7d7e51b2876c5b9eea0ef916ba28", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "zendframework/zend-http": "^2.5.4", + "zendframework/zend-server": "^2.6.1", + "zendframework/zend-stdlib": "^2.5 || ^3.0", + "zendframework/zendxml": "^1.0.2" + }, + "suggest": { + "zendframework/zend-http": "Zend\\Http component, required to use Zend\\Json\\Server", + "zendframework/zend-server": "Zend\\Server component, required to use Zend\\Json\\Server", + "zendframework/zend-stdlib": "Zend\\Stdlib component, for use with caching Zend\\Json\\Server responses", + "zendframework/zendxml": "To support Zend\\Json\\Json::fromXml() usage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev", + "dev-develop": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Json\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", + "homepage": "https://github.com/zendframework/zend-json", + "keywords": [ + "json", + "zf2" + ], + "time": "2016-02-04 21:20:26" + }, + { + "name": "zendframework/zend-loader", + "version": "2.5.1", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-loader.git", + "reference": "c5fd2f071bde071f4363def7dea8dec7393e135c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-loader/zipball/c5fd2f071bde071f4363def7dea8dec7393e135c", + "reference": "c5fd2f071bde071f4363def7dea8dec7393e135c", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Loader\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "homepage": "https://github.com/zendframework/zend-loader", + "keywords": [ + "loader", + "zf2" + ], + "time": "2015-06-03 14:05:47" + }, + { + "name": "zendframework/zend-stdlib", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-stdlib.git", + "reference": "22eb098958980fbbe6b9a06f209f5a4b496cc0c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/22eb098958980fbbe6b9a06f209f5a4b496cc0c1", + "reference": "22eb098958980fbbe6b9a06f209f5a4b496cc0c1", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0" + }, + "require-dev": { + "athletic/athletic": "~0.1", + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev", + "dev-develop": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Stdlib\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "homepage": "https://github.com/zendframework/zend-stdlib", + "keywords": [ + "stdlib", + "zf2" + ], + "time": "2016-02-03 16:53:37" + }, + { + "name": "zendframework/zend-uri", + "version": "2.5.2", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-uri.git", + "reference": "0bf717a239432b1a1675ae314f7c4acd742749ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-uri/zipball/0bf717a239432b1a1675ae314f7c4acd742749ed", + "reference": "0bf717a239432b1a1675ae314f7c4acd742749ed", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "zendframework/zend-escaper": "^2.5", + "zendframework/zend-validator": "^2.5" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Uri\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)", + "homepage": "https://github.com/zendframework/zend-uri", + "keywords": [ + "uri", + "zf2" + ], + "time": "2016-02-17 22:38:51" + }, + { + "name": "zendframework/zend-validator", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-validator.git", + "reference": "1315fead53358054e3f5fcf440c1a4cd5f0724db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/1315fead53358054e3f5fcf440c1a4cd5f0724db", + "reference": "1315fead53358054e3f5fcf440c1a4cd5f0724db", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "^1.1", + "php": "^5.5 || ^7.0", + "zendframework/zend-stdlib": "^2.7 || ^3.0" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "^4.0", + "zendframework/zend-cache": "^2.6.1", + "zendframework/zend-config": "^2.6", + "zendframework/zend-db": "^2.5", + "zendframework/zend-filter": "^2.6", + "zendframework/zend-http": "^2.5.4", + "zendframework/zend-i18n": "^2.6", + "zendframework/zend-math": "^2.6", + "zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3", + "zendframework/zend-session": "^2.5", + "zendframework/zend-uri": "^2.5" + }, + "suggest": { + "zendframework/zend-db": "Zend\\Db component", + "zendframework/zend-filter": "Zend\\Filter component, required by the Digits validator", + "zendframework/zend-i18n": "Zend\\I18n component to allow translation of validation error messages as well as to use the various Date validators", + "zendframework/zend-i18n-resources": "Translations of validator messages", + "zendframework/zend-math": "Zend\\Math component", + "zendframework/zend-servicemanager": "Zend\\ServiceManager component to allow using the ValidatorPluginManager and validator chains", + "zendframework/zend-session": "Zend\\Session component", + "zendframework/zend-uri": "Zend\\Uri component, required by the Uri and Sitemap\\Loc validators" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev", + "dev-develop": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Validator\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a set of commonly needed validators", + "homepage": "https://github.com/zendframework/zend-validator", + "keywords": [ + "validator", + "zf2" + ], + "time": "2016-02-17 17:59:34" + }, + { + "name": "zendframework/zendservice-apple-apns", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/zendframework/ZendService_Apple_Apns.git", + "reference": "ee2c44ee833206c1eb95b2fb7be1e2335e7570eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/ZendService_Apple_Apns/zipball/ee2c44ee833206c1eb95b2fb7be1e2335e7570eb", + "reference": "ee2c44ee833206c1eb95b2fb7be1e2335e7570eb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-json": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "ZendService\\Apple\\Apns\\": "library/", + "ZendService\\Apple\\Exception\\": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "OOP Zend Framework 2 wrapper for Apple Push Notification Service", + "homepage": "http://packages.zendframework.com/", + "keywords": [ + "apns", + "apple", + "notification", + "push", + "zf2" + ], + "time": "2015-12-09 22:55:07" + }, + { + "name": "zendframework/zendservice-google-gcm", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/zendframework/ZendService_Google_Gcm.git", + "reference": "86d16e9dcb4d41677e6f691642856b3eb95a1073" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/ZendService_Google_Gcm/zipball/86d16e9dcb4d41677e6f691642856b3eb95a1073", + "reference": "86d16e9dcb4d41677e6f691642856b3eb95a1073", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-http": ">=2.0.0", + "zendframework/zend-json": ">=2.0.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "ZendService\\Google\\Gcm\\": "library/", + "ZendService\\Google\\Exception\\": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "OOP wrapper for Google Cloud Messaging", + "homepage": "http://packages.zendframework.com/", + "keywords": [ + "gcm", + "google", + "notification", + "push", + "zf2" + ], + "time": "2015-10-14 03:18:56" + }, { "name": "zircote/swagger-php", "version": "2.0.6", @@ -8670,6 +9296,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "turbo124/laravel-push-notification": 20, "omnipay/mollie": 20, "omnipay/2checkout": 20, "omnipay/gocardless": 20, diff --git a/config/app.php b/config/app.php index dff5b99de6f0..59a67d677706 100644 --- a/config/app.php +++ b/config/app.php @@ -164,6 +164,7 @@ return [ 'App\Providers\RouteServiceProvider', 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', + 'Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider', ], /* @@ -249,6 +250,7 @@ return [ 'Rocketeer' => 'Rocketeer\Facades\Rocketeer', 'Socialite' => 'Laravel\Socialite\Facades\Socialite', 'Excel' => 'Maatwebsite\Excel\Facades\Excel', + 'PushNotification' => 'Davibennun\LaravelPushNotification\Facades\PushNotification', ], diff --git a/config/push-notification.php b/config/push-notification.php new file mode 100644 index 000000000000..89dd441ab531 --- /dev/null +++ b/config/push-notification.php @@ -0,0 +1,23 @@ + [ + 'environment' =>'development', + 'certificate'=>app_path().'/certs/ninjaIOS.pem', + 'passPhrase' =>'', + 'service' =>'apns' + ], + 'ninjaIOS' => [ + 'environment' =>'production', + 'certificate'=>app_path().'/certs/productionNinjaIOS.pem', + 'passPhrase' =>'', + 'service' =>'apns' + ], + 'ninjaAndroid' => [ + 'environment' =>'production', + 'apiKey' =>'yourAPIKey', + 'service' =>'gcm' + ] + +]; \ No newline at end of file