From 50ddbcf609e213c344114345c213d91a228fb464 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 29 Feb 2016 21:31:58 +1100 Subject: [PATCH 1/8] iOS Push Notifications --- app/Http/routes.php | 3 + app/Ninja/Notifications/PushFactory.php | 89 +++ composer.json | 1 + composer.lock | 816 +++++++++++++++++++++--- config/app.php | 2 + config/push-notification.php | 23 + 6 files changed, 840 insertions(+), 94 deletions(-) create mode 100644 app/Ninja/Notifications/PushFactory.php create mode 100644 config/push-notification.php diff --git a/app/Http/routes.php b/app/Http/routes.php index 1a92403770..2bfa12d5b1 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -552,6 +552,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/Ninja/Notifications/PushFactory.php b/app/Ninja/Notifications/PushFactory.php new file mode 100644 index 0000000000..8a28e2832a --- /dev/null +++ b/app/Ninja/Notifications/PushFactory.php @@ -0,0 +1,89 @@ +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/composer.json b/composer.json index fc27b248f6..f73bbc81aa 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 85106bb133..302f92e2e9 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": "1cacd0ee0b218236e50fe5e72c863575", - "content-hash": "9addb5dadcabaeb89d182f1bebcd2137", + "hash": "3ea5a24db3c58119a78e8f320565549a", + "content-hash": "21e67c50027194058bf4ceaa0d20a390", "packages": [ { "name": "agmscode/omnipay-agms", @@ -901,6 +901,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", @@ -3745,16 +3772,16 @@ }, { "name": "nikic/php-parser", - "version": "v2.0.0", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "c542e5d86a9775abd1021618eb2430278bfc1e01" + "reference": "ce5be709d59b32dd8a88c80259028759991a4206" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c542e5d86a9775abd1021618eb2430278bfc1e01", - "reference": "c542e5d86a9775abd1021618eb2430278bfc1e01", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ce5be709d59b32dd8a88c80259028759991a4206", + "reference": "ce5be709d59b32dd8a88c80259028759991a4206", "shasum": "" }, "require": { @@ -3792,7 +3819,7 @@ "parser", "php" ], - "time": "2015-12-04 15:28:43" + "time": "2016-02-28 19:48:28" }, { "name": "omnipay/2checkout", @@ -4613,7 +4640,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay-mollie/zipball/efd491fdac7d1243e2dd1da5a964514e3aab2a5a", + "url": "https://api.github.com/repos/thephpleague/omnipay-mollie/zipball/a89cb0d15447023b24c03f86873c1c1489cd021b", "reference": "22956c1a62a9662afa5f5d119723b413770ac525", "shasum": "" }, @@ -4662,16 +4689,16 @@ }, { "name": "omnipay/multisafepay", - "version": "V2.2.0", + "version": "v2.3.0", "source": { "type": "git", "url": "https://github.com/thephpleague/omnipay-multisafepay.git", - "reference": "a0f09abf404ca0dd21b553578d7f95df2bfa5318" + "reference": "342d0a3ba1a5ef0d788f20d23d0c70ce04ec3de1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay-multisafepay/zipball/a0f09abf404ca0dd21b553578d7f95df2bfa5318", - "reference": "a0f09abf404ca0dd21b553578d7f95df2bfa5318", + "url": "https://api.github.com/repos/thephpleague/omnipay-multisafepay/zipball/342d0a3ba1a5ef0d788f20d23d0c70ce04ec3de1", + "reference": "342d0a3ba1a5ef0d788f20d23d0c70ce04ec3de1", "shasum": "" }, "require": { @@ -4716,7 +4743,7 @@ "pay", "payment" ], - "time": "2015-01-14 04:01:43" + "time": "2016-02-18 00:06:08" }, { "name": "omnipay/netaxept", @@ -5123,16 +5150,16 @@ }, { "name": "omnipay/paypal", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/thephpleague/omnipay-paypal.git", - "reference": "2b3624b0d3f359c10c99b83c43f091ac397597b9" + "reference": "97fc3b1ff43e130ee911b35e139dcc853488d07a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay-paypal/zipball/2b3624b0d3f359c10c99b83c43f091ac397597b9", - "reference": "2b3624b0d3f359c10c99b83c43f091ac397597b9", + "url": "https://api.github.com/repos/thephpleague/omnipay-paypal/zipball/97fc3b1ff43e130ee911b35e139dcc853488d07a", + "reference": "97fc3b1ff43e130ee911b35e139dcc853488d07a", "shasum": "" }, "require": { @@ -5177,7 +5204,7 @@ "paypal", "purchase" ], - "time": "2016-02-16 00:01:31" + "time": "2016-02-29 00:06:43" }, { "name": "omnipay/pin", @@ -6011,6 +6038,70 @@ ], "time": "2015-12-10 10:27:22" }, + { + "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", @@ -6118,7 +6209,7 @@ }, { "name": "symfony/class-loader", - "version": "v3.0.2", + "version": "v3.0.3", "source": { "type": "git", "url": "https://github.com/symfony/class-loader.git", @@ -6174,16 +6265,16 @@ }, { "name": "symfony/console", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d3fc138b6ed8f8074591821d3416d8f9c04d6ca6" + "reference": "ee91ec301cd88ee38ab14505025fe94bbc19a9c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d3fc138b6ed8f8074591821d3416d8f9c04d6ca6", - "reference": "d3fc138b6ed8f8074591821d3416d8f9c04d6ca6", + "url": "https://api.github.com/repos/symfony/console/zipball/ee91ec301cd88ee38ab14505025fe94bbc19a9c1", + "reference": "ee91ec301cd88ee38ab14505025fe94bbc19a9c1", "shasum": "" }, "require": { @@ -6229,20 +6320,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-01-14 08:26:43" + "time": "2016-02-28 16:19:47" }, { "name": "symfony/css-selector", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "1a869e59cc3b2802961fc2124139659e12b72fe5" + "reference": "5377825bb6496514f63603af417fa07afaa12357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/1a869e59cc3b2802961fc2124139659e12b72fe5", - "reference": "1a869e59cc3b2802961fc2124139659e12b72fe5", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/5377825bb6496514f63603af417fa07afaa12357", + "reference": "5377825bb6496514f63603af417fa07afaa12357", "shasum": "" }, "require": { @@ -6282,20 +6373,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:32:00" + "time": "2016-01-27 05:09:39" }, { "name": "symfony/debug", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "5aca4aa9600b943287b4a1799a4d1d78b5388175" + "reference": "e96f1ff28e2b8b2f3b906245b18d5e6a52e73648" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/5aca4aa9600b943287b4a1799a4d1d78b5388175", - "reference": "5aca4aa9600b943287b4a1799a4d1d78b5388175", + "url": "https://api.github.com/repos/symfony/debug/zipball/e96f1ff28e2b8b2f3b906245b18d5e6a52e73648", + "reference": "e96f1ff28e2b8b2f3b906245b18d5e6a52e73648", "shasum": "" }, "require": { @@ -6339,20 +6430,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-01-13 07:57:33" + "time": "2016-01-25 23:34:19" }, { "name": "symfony/dom-crawler", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "55cc79a177193eb3bd74ac54b353691fbb211d3a" + "reference": "c7a6dfd2720581a61d06c04489e9b3df1e4f7eaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/55cc79a177193eb3bd74ac54b353691fbb211d3a", - "reference": "55cc79a177193eb3bd74ac54b353691fbb211d3a", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c7a6dfd2720581a61d06c04489e9b3df1e4f7eaf", + "reference": "c7a6dfd2720581a61d06c04489e9b3df1e4f7eaf", "shasum": "" }, "require": { @@ -6394,20 +6485,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:32:00" + "time": "2016-02-28 16:19:47" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.2", + "version": "v2.8.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ee278f7c851533e58ca307f66305ccb9188aceda" + "reference": "78c468665c9568c3faaa9c416a7134308f2d85c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ee278f7c851533e58ca307f66305ccb9188aceda", - "reference": "ee278f7c851533e58ca307f66305ccb9188aceda", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/78c468665c9568c3faaa9c416a7134308f2d85c3", + "reference": "78c468665c9568c3faaa9c416a7134308f2d85c3", "shasum": "" }, "require": { @@ -6454,20 +6545,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-01-13 10:28:07" + "time": "2016-01-27 05:14:19" }, { "name": "symfony/finder", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "d20ac81c81a67ab898b0c0afa435f3e9a7d460cf" + "reference": "addcb70b33affbca4f3979b0d000259b63dd6711" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/d20ac81c81a67ab898b0c0afa435f3e9a7d460cf", - "reference": "d20ac81c81a67ab898b0c0afa435f3e9a7d460cf", + "url": "https://api.github.com/repos/symfony/finder/zipball/addcb70b33affbca4f3979b0d000259b63dd6711", + "reference": "addcb70b33affbca4f3979b0d000259b63dd6711", "shasum": "" }, "require": { @@ -6503,20 +6594,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-01-14 08:26:43" + "time": "2016-02-22 16:12:29" }, { "name": "symfony/http-foundation", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "2f9d240056f026af5f7ba7f7052b0c6709bf288c" + "reference": "6aeb70d26da8f30753111b3f9cf47eb0421c0735" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/2f9d240056f026af5f7ba7f7052b0c6709bf288c", - "reference": "2f9d240056f026af5f7ba7f7052b0c6709bf288c", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/6aeb70d26da8f30753111b3f9cf47eb0421c0735", + "reference": "6aeb70d26da8f30753111b3f9cf47eb0421c0735", "shasum": "" }, "require": { @@ -6558,20 +6649,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2016-01-13 10:26:43" + "time": "2016-02-28 16:19:47" }, { "name": "symfony/http-kernel", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "aa2f1e544d6cb862452504b5479a5095b7bfc53f" + "reference": "11082f03c03e17dd2ca9c149988b229e04829fdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/aa2f1e544d6cb862452504b5479a5095b7bfc53f", - "reference": "aa2f1e544d6cb862452504b5479a5095b7bfc53f", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/11082f03c03e17dd2ca9c149988b229e04829fdc", + "reference": "11082f03c03e17dd2ca9c149988b229e04829fdc", "shasum": "" }, "require": { @@ -6640,7 +6731,61 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2016-01-14 10:41:45" + "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", @@ -6752,16 +6897,16 @@ }, { "name": "symfony/process", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "0570b9ca51135ee7da0f19239eaf7b07ffb87034" + "reference": "faa89438017392585abdf7f5a47f3f5f282d93c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/0570b9ca51135ee7da0f19239eaf7b07ffb87034", - "reference": "0570b9ca51135ee7da0f19239eaf7b07ffb87034", + "url": "https://api.github.com/repos/symfony/process/zipball/faa89438017392585abdf7f5a47f3f5f282d93c1", + "reference": "faa89438017392585abdf7f5a47f3f5f282d93c1", "shasum": "" }, "require": { @@ -6797,20 +6942,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-01-06 09:57:37" + "time": "2016-02-02 13:32:58" }, { "name": "symfony/routing", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "6fec77993acfe19aecf60544b9c7d32f3d5b2506" + "reference": "c63128f6dd5095351a87cd7c8801963001e22aff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/6fec77993acfe19aecf60544b9c7d32f3d5b2506", - "reference": "6fec77993acfe19aecf60544b9c7d32f3d5b2506", + "url": "https://api.github.com/repos/symfony/routing/zipball/c63128f6dd5095351a87cd7c8801963001e22aff", + "reference": "c63128f6dd5095351a87cd7c8801963001e22aff", "shasum": "" }, "require": { @@ -6832,6 +6977,7 @@ "doctrine/annotations": "For using the annotation loader", "symfony/config": "For using the all-in-one router or any loader", "symfony/expression-language": "For using expression matching", + "symfony/http-foundation": "For using a Symfony Request object", "symfony/yaml": "For using the YAML loader" }, "type": "library", @@ -6870,20 +7016,20 @@ "uri", "url" ], - "time": "2016-01-03 15:32:00" + "time": "2016-02-04 13:52:46" }, { "name": "symfony/translation", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "8cbab8445ad4269427077ba02fff8718cb397e22" + "reference": "4c61cf815af17eee4cebf0e4c66f56a2f704cfd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/8cbab8445ad4269427077ba02fff8718cb397e22", - "reference": "8cbab8445ad4269427077ba02fff8718cb397e22", + "url": "https://api.github.com/repos/symfony/translation/zipball/4c61cf815af17eee4cebf0e4c66f56a2f704cfd8", + "reference": "4c61cf815af17eee4cebf0e4c66f56a2f704cfd8", "shasum": "" }, "require": { @@ -6933,20 +7079,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:32:00" + "time": "2016-02-01 20:45:15" }, { "name": "symfony/var-dumper", - "version": "v2.7.9", + "version": "v2.7.10", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "ad39199e91f2f845a0181b14d459fda13a622138" + "reference": "e4fdc92abb3dae0d840f4276af701d58ddc9b733" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ad39199e91f2f845a0181b14d459fda13a622138", - "reference": "ad39199e91f2f845a0181b14d459fda13a622138", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e4fdc92abb3dae0d840f4276af701d58ddc9b733", + "reference": "e4fdc92abb3dae0d840f4276af701d58ddc9b733", "shasum": "" }, "require": { @@ -6992,7 +7138,7 @@ "debug", "dump" ], - "time": "2016-01-07 11:12:32" + "time": "2016-02-12 17:39:33" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -7087,6 +7233,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", @@ -7358,6 +7546,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", @@ -8360,16 +8987,16 @@ }, { "name": "sebastian/environment", - "version": "1.3.3", + "version": "1.3.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e7133793a8e5a5714a551a8324337374be209df" + "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df", - "reference": "6e7133793a8e5a5714a551a8324337374be209df", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf", + "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf", "shasum": "" }, "require": { @@ -8406,7 +9033,7 @@ "environment", "hhvm" ], - "time": "2015-12-02 08:37:27" + "time": "2016-02-26 18:40:46" }, { "name": "sebastian/exporter", @@ -8615,16 +9242,16 @@ }, { "name": "symfony/browser-kit", - "version": "v2.8.2", + "version": "v2.8.3", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "a93dffaf763182acad12a4c42c7efc372899891e" + "reference": "6b2085020b4e86fcb7ae44c3ab8ddb91774b33d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/a93dffaf763182acad12a4c42c7efc372899891e", - "reference": "a93dffaf763182acad12a4c42c7efc372899891e", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/6b2085020b4e86fcb7ae44c3ab8ddb91774b33d2", + "reference": "6b2085020b4e86fcb7ae44c3ab8ddb91774b33d2", "shasum": "" }, "require": { @@ -8668,20 +9295,20 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2016-01-12 17:46:01" + "time": "2016-01-27 11:34:40" }, { "name": "symfony/yaml", - "version": "v3.0.2", + "version": "v3.0.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "3cf0709d7fe936e97bee9e954382e449003f1d9a" + "reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3cf0709d7fe936e97bee9e954382e449003f1d9a", - "reference": "3cf0709d7fe936e97bee9e954382e449003f1d9a", + "url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c", + "reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c", "shasum": "" }, "require": { @@ -8717,12 +9344,13 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-02-02 13:44:19" + "time": "2016-02-23 15:16:06" } ], "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 dff5b99de6..59a67d6777 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 0000000000..f3d2a034f7 --- /dev/null +++ b/config/push-notification.php @@ -0,0 +1,23 @@ + array( + 'environment' =>'development', + 'certificate'=>app_path().'/certs/ninjaIOS.pem', + 'passPhrase' =>'', + 'service' =>'apns' + ), + 'ninjaIOS' => array( + 'environment' =>'production', + 'certificate'=>app_path().'/certs/productionNinjaIOS.pem', + 'passPhrase' =>'', + 'service' =>'apns' + ), + 'ninjaAndroid' => array( + 'environment' =>'production', + 'apiKey' =>'yourAPIKey', + 'service' =>'gcm' + ) + +]; \ No newline at end of file From 2cd3571f253428c119816b3d908dab219261304a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 29 Feb 2016 21:35:14 +1100 Subject: [PATCH 2/8] iOS Push Notifications --- app/Ninja/Notifications/PushFactory.php | 7 +++++++ config/push-notification.php | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/Ninja/Notifications/PushFactory.php b/app/Ninja/Notifications/PushFactory.php index 8a28e2832a..7f882ff1d0 100644 --- a/app/Ninja/Notifications/PushFactory.php +++ b/app/Ninja/Notifications/PushFactory.php @@ -14,6 +14,13 @@ class PushFactory { /** * PushFactory constructor. + * + * @param $this->certificate - Development or production. + * + * Static variables defined in routes.php + * + * IOS_PRODUCTION_PUSH + * IOS_DEV_PUSH */ public function __construct() diff --git a/config/push-notification.php b/config/push-notification.php index f3d2a034f7..89dd441ab5 100644 --- a/config/push-notification.php +++ b/config/push-notification.php @@ -2,22 +2,22 @@ return [ - 'devNinjaIOS' => array( + 'devNinjaIOS' => [ 'environment' =>'development', 'certificate'=>app_path().'/certs/ninjaIOS.pem', 'passPhrase' =>'', 'service' =>'apns' - ), - 'ninjaIOS' => array( + ], + 'ninjaIOS' => [ 'environment' =>'production', 'certificate'=>app_path().'/certs/productionNinjaIOS.pem', 'passPhrase' =>'', 'service' =>'apns' - ), - 'ninjaAndroid' => array( + ], + 'ninjaAndroid' => [ 'environment' =>'production', 'apiKey' =>'yourAPIKey', 'service' =>'gcm' - ) + ] ]; \ No newline at end of file From f6be1041b7f820b6e908bfe081a6b4616d8473fb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 29 Feb 2016 22:21:15 +1100 Subject: [PATCH 3/8] iOS Push Notifications --- app/Listeners/NotificationListener.php | 12 ++++++- app/Ninja/Notifications/PushService.php | 44 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 app/Ninja/Notifications/PushService.php diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php index aba3044575..c7b58fe30b 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/PushService.php b/app/Ninja/Notifications/PushService.php new file mode 100644 index 0000000000..c304ed14d2 --- /dev/null +++ b/app/Ninja/Notifications/PushService.php @@ -0,0 +1,44 @@ +pushFactory = $pushFactory; + } + + /** + * @param $invoice - Invoice object + * @param $type - Type of notification, ie. Quote APPROVED, Invoice PAID, Invoice SENT, Invoice 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 + + //loop and send + + } + + private function checkDeviceExists($account) + { + $devices = json_decode($account->devices); + + + } +} \ No newline at end of file From 57a4a24294ed4b9a01455158d9e758a5fe683559 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Mar 2016 11:31:16 +1100 Subject: [PATCH 4/8] Push Notifications --- app/Ninja/Notifications/PushService.php | 96 +++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/app/Ninja/Notifications/PushService.php b/app/Ninja/Notifications/PushService.php index c304ed14d2..0816a8c1ff 100644 --- a/app/Ninja/Notifications/PushService.php +++ b/app/Ninja/Notifications/PushService.php @@ -9,6 +9,17 @@ use Illuminate\Http\Request; * @package App\Ninja\Notifications */ + +/** + * $account->devices Definition + * + * @param string token + * @param bool notify_sent + * @param bool notify_paid + * @param bool notify_approved + * @param bool notify_viewed + */ + class PushService { protected $pushFactory; @@ -20,7 +31,7 @@ class PushService /** * @param $invoice - Invoice object - * @param $type - Type of notification, ie. Quote APPROVED, Invoice PAID, Invoice SENT, Invoice VIEWED + * @param $type - Type of notification, ie. Quote APPROVED, Invoice PAID, Invoice/Quote SENT, Invoice/Quote VIEWED */ public function sendNotification($invoice, $type) @@ -30,15 +41,92 @@ class PushService 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) + $this->pushMessage($invoice, $device['token'], $device["notify_{$type}"]); + } - //loop and send } + + 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); + $devices = json_decode($account->devices, TRUE); - + if(count($devices) >= 1) + return TRUE; + else + return FALSE; } + + 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; + } + } + + private function entitySentMessage($invoice) + { + if($invoice->is_quote) + return 'Quote #{$invoice->invoice_number} sent!'; + else + return 'Invoice #{$invoice->invoice_number} sent!'; + + } + + private function invoicePaidMessage($invoice) + { + return 'Invoice #{$invoice->invoice_number} paid!'; + } + + private function quoteApprovedMessage($invoice) + { + return 'Quote #{$invoice->invoice_number} approved!'; + } + + 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 From f1bc597034fbbbbbc86fa84f9dc809ce6ebb5c14 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Mar 2016 13:57:59 +1100 Subject: [PATCH 5/8] Push Notifications --- app/Http/Controllers/AccountApiController.php | 36 +++++++++++++++++ app/Http/routes.php | 1 + .../PushService.php | 39 +++++++++++++++++-- 3 files changed, 72 insertions(+), 4 deletions(-) rename app/{Ninja/Notifications => Services}/PushService.php (79%) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 77e85243d7..b8a2a6a049 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -117,4 +117,40 @@ 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); + + if(count($devices) >= 1) { + foreach ($devices as $device) { + if ($device['email'] == Auth::user()->username) { + $device['token'] = $request->token; //update + 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); + + } + } diff --git a/app/Http/routes.php b/app/Http/routes.php index 2bfa12d5b1..9cfb2ed94e 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -235,6 +235,7 @@ 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'); // Vendor Route::resource('vendors', 'VendorApiController'); diff --git a/app/Ninja/Notifications/PushService.php b/app/Services/PushService.php similarity index 79% rename from app/Ninja/Notifications/PushService.php rename to app/Services/PushService.php index 0816a8c1ff..c33859bc24 100644 --- a/app/Ninja/Notifications/PushService.php +++ b/app/Services/PushService.php @@ -1,9 +1,9 @@ devices Definition * - * @param string token + * @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 @@ -24,6 +26,9 @@ class PushService { protected $pushFactory; + /** + * @param PushFactory $pushFactory + */ public function __construct(PushFactory $pushFactory) { $this->pushFactory = $pushFactory; @@ -45,7 +50,7 @@ class PushService foreach($devices as $device) { - if($device["notify_{$type}"] == TRUE) + if(($device["notify_{$type}"] == TRUE) && ($device['device'] == 'ios')) $this->pushMessage($invoice, $device['token'], $device["notify_{$type}"]); } @@ -53,6 +58,11 @@ class PushService } + /** + * @param $invoice + * @param $token + * @param $type + */ private function pushMessage($invoice, $token, $type) { $this->pushFactory->message($token, $this->messageType($invoice, $type)); @@ -77,6 +87,11 @@ class PushService return FALSE; } + /** + * @param $invoice + * @param $type + * @return string + */ private function messageType($invoice, $type) { switch($type) @@ -99,6 +114,10 @@ class PushService } } + /** + * @param $invoice + * @return string + */ private function entitySentMessage($invoice) { if($invoice->is_quote) @@ -108,16 +127,28 @@ class PushService } + /** + * @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) From 2438195c08a117511bc699015c3706886445f4ba Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Mar 2016 14:00:11 +1100 Subject: [PATCH 6/8] Push Notifications --- app/Services/PushService.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Services/PushService.php b/app/Services/PushService.php index c33859bc24..00591e2633 100644 --- a/app/Services/PushService.php +++ b/app/Services/PushService.php @@ -59,6 +59,10 @@ class PushService /** + * pushMessage function + * + * method to dispatch iOS notifications + * * @param $invoice * @param $token * @param $type @@ -88,6 +92,10 @@ class PushService } /** + * messageType function + * + * method which formats an appropriate message depending on message type + * * @param $invoice * @param $type * @return string From 1aef96f027fe155f0aa2dead24091186db5a8eff Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Mar 2016 14:44:14 +1100 Subject: [PATCH 7/8] Push Notifications --- app/Http/Controllers/AccountApiController.php | 34 +++++++++++++++++++ app/Http/routes.php | 1 + 2 files changed, 35 insertions(+) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index b8a2a6a049..0c4e1c81fa 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -153,4 +153,38 @@ class AccountApiController extends BaseAPIController } + 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 9cfb2ed94e..c00eb8f8e9 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -236,6 +236,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function() 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'); From 6e3b1ecb4ba871be5f5b78c0b8de4182abb70eda Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Mar 2016 15:06:54 +1100 Subject: [PATCH 8/8] Push Notifications --- app/Http/Controllers/AccountApiController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 0c4e1c81fa..6d4ef0ccf1 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -125,14 +125,17 @@ class AccountApiController extends BaseAPIController //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); - if(count($devices) >= 1) { - foreach ($devices as $device) { - if ($device['email'] == Auth::user()->username) { - $device['token'] = $request->token; //update + + 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 = [