diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-09-26 01:35:13 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-09-26 01:35:13 +0200 |
| commit | 597fa051833ca3df6eb185c0143ff82e02dacba1 (patch) | |
| tree | cb25347477c57f82e955b054b70f4bb5359fb0d2 /StoneIsland/platforms/ios/www | |
| parent | 6a9186aea6b85beef28e3eb765fbf2322a1c7890 (diff) | |
push plugin ugh
Diffstat (limited to 'StoneIsland/platforms/ios/www')
7 files changed, 285 insertions, 369 deletions
diff --git a/StoneIsland/platforms/ios/www/cordova.js b/StoneIsland/platforms/ios/www/cordova.js index 29be9099..3540a020 100644 --- a/StoneIsland/platforms/ios/www/cordova.js +++ b/StoneIsland/platforms/ios/www/cordova.js @@ -1,5 +1,5 @@ // Platform: ios -// a3732cb71d9b1dd590338e8cf44196f366d46da3 +// 7c5fcc5a5adfbf3fb8ceaf36fbdd4bd970bd9c20 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -19,7 +19,7 @@ under the License. */ ;(function() { -var PLATFORM_VERSION_BUILD_LABEL = '4.3.1'; +var PLATFORM_VERSION_BUILD_LABEL = '4.4.0'; // file: src/scripts/require.js /*jshint -W079 */ diff --git a/StoneIsland/platforms/ios/www/cordova_plugins.js b/StoneIsland/platforms/ios/www/cordova_plugins.js index 9005406d..5d4c04be 100644 --- a/StoneIsland/platforms/ios/www/cordova_plugins.js +++ b/StoneIsland/platforms/ios/www/cordova_plugins.js @@ -107,6 +107,14 @@ module.exports = [ ] }, { + "id": "cordova-plugin-statusbar.statusbar", + "file": "plugins/cordova-plugin-statusbar/www/statusbar.js", + "pluginId": "cordova-plugin-statusbar", + "clobbers": [ + "window.StatusBar" + ] + }, + { "id": "cordova-plugin-x-socialsharing.SocialSharing", "file": "plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js", "pluginId": "cordova-plugin-x-socialsharing", @@ -130,27 +138,12 @@ module.exports = [ "clobbers": [ "PushNotification" ] - }, - { - "id": "cordova-plugin-statusbar.statusbar", - "file": "plugins/cordova-plugin-statusbar/www/statusbar.js", - "pluginId": "cordova-plugin-statusbar", - "clobbers": [ - "window.StatusBar" - ] - }, - { - "id": "cordova-plugin-firebase.FirebasePlugin", - "file": "plugins/cordova-plugin-firebase/www/firebase.js", - "pluginId": "cordova-plugin-firebase", - "clobbers": [ - "FirebasePlugin" - ] } ]; module.exports.metadata = // TOP OF METADATA { + "cordova-plugin-app-name": "1.0.4", "cordova-plugin-compat": "1.1.0", "cordova-plugin-console": "1.0.4", "cordova-plugin-customurlscheme": "4.2.0", @@ -160,13 +153,11 @@ module.exports.metadata = "cordova-plugin-inappbrowser": "1.5.0", "cordova-plugin-network-information": "1.3.0", "cordova-plugin-splashscreen": "4.0.0", + "cordova-plugin-statusbar": "2.2.3", "cordova-plugin-whitelist": "1.3.0", "cordova-plugin-x-socialsharing": "5.1.3", "ionic-plugin-keyboard": "2.2.1", - "phonegap-plugin-push": "1.9.2", - "cordova-plugin-statusbar": "2.2.3", - "cordova-plugin-firebase": "0.1.24", - "cordova-plugin-app-name": "1.0.4" + "phonegap-plugin-push": "2.0.0" }; // BOTTOM OF METADATA });
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/_router.js b/StoneIsland/platforms/ios/www/js/lib/_router.js index 43438854..19bd3247 100755 --- a/StoneIsland/platforms/ios/www/js/lib/_router.js +++ b/StoneIsland/platforms/ios/www/js/lib/_router.js @@ -88,7 +88,7 @@ var SiteRouter = Router.extend({ app.view = app[name] } - window.FirebasePlugin && window.FirebasePlugin.setScreenName(name) + // window.FirebasePlugin && window.FirebasePlugin.setScreenName(name) app.header.set_back( !! app.view.back ) app.view.show() diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/push.js b/StoneIsland/platforms/ios/www/js/lib/etc/push.js index 00a2e839..f3f3132e 100755 --- a/StoneIsland/platforms/ios/www/js/lib/etc/push.js +++ b/StoneIsland/platforms/ios/www/js/lib/etc/push.js @@ -7,7 +7,7 @@ var push = (function(){ push.disabled = true return } - + pushPlugin = PushNotification.init({ ios: { alert: true, @@ -130,9 +130,10 @@ var push = (function(){ if (push_obj.additionalData.foreground === false) { // TODO: route the user to the uri in push_obj pushPlugin.finish(function(){}, function(){}) - } - else if (push_obj.additionalData.url) { - app.router.go(push_obj.additionalData.url) + + if (push_obj.additionalData.url) { + app.router.go(push_obj.additionalData.url) + } } else if (is_hub) { app.router.go("hub") diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js index 2743946a..6972b436 100755 --- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js @@ -167,7 +167,7 @@ var ProductView = ScrollableView.extend({ this.$price.html(price) this.$body.html(body) - window.FirebasePlugin && window.FirebasePlugin.setScreenName('product:' + code) + // window.FirebasePlugin && window.FirebasePlugin.setScreenName('product:' + code) this.$productHeader.toggleClass("wide", title.length > 48) diff --git a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-firebase/www/firebase.js b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-firebase/www/firebase.js deleted file mode 100644 index e1e423d1..00000000 --- a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-firebase/www/firebase.js +++ /dev/null @@ -1,124 +0,0 @@ -cordova.define("cordova-plugin-firebase.FirebasePlugin", function(require, exports, module) { -var exec = require('cordova/exec'); - -exports.getInstanceId = function(success, error) { - exec(success, error, "FirebasePlugin", "getInstanceId", []); -}; - -exports.getToken = function(success, error) { - exec(success, error, "FirebasePlugin", "getToken", []); -}; - -exports.onNotificationOpen = function(success, error) { - exec(success, error, "FirebasePlugin", "onNotificationOpen", []); -}; - -exports.onTokenRefresh = function(success, error) { - exec(success, error, "FirebasePlugin", "onTokenRefresh", []); -}; - -exports.grantPermission = function(success, error) { - exec(success, error, "FirebasePlugin", "grantPermission", []); -}; - -exports.hasPermission = function(success, error) { - exec(success, error, "FirebasePlugin", "hasPermission", []); -}; - -exports.setBadgeNumber = function(number, success, error) { - exec(success, error, "FirebasePlugin", "setBadgeNumber", [number]); -}; - -exports.getBadgeNumber = function(success, error) { - exec(success, error, "FirebasePlugin", "getBadgeNumber", []); -}; - -exports.subscribe = function(topic, success, error) { - exec(success, error, "FirebasePlugin", "subscribe", [topic]); -}; - -exports.unsubscribe = function(topic, success, error) { - exec(success, error, "FirebasePlugin", "unsubscribe", [topic]); -}; - -exports.unregister = function(success, error) { - exec(success, error, "FirebasePlugin", "unregister", []); -}; - -exports.logEvent = function(name, params, success, error) { - exec(success, error, "FirebasePlugin", "logEvent", [name, params]); -}; - -exports.logError = function(message, success, error) { - exec(success, error, "FirebasePlugin", "logError", [message]); -}; - -exports.setScreenName = function(name, success, error) { - exec(success, error, "FirebasePlugin", "setScreenName", [name]); -}; - -exports.setUserId = function(id, success, error) { - exec(success, error, "FirebasePlugin", "setUserId", [id]); -}; - -exports.setUserProperty = function(name, value, success, error) { - exec(success, error, "FirebasePlugin", "setUserProperty", [name, value]); -}; - -exports.activateFetched = function (success, error) { - exec(success, error, "FirebasePlugin", "activateFetched", []); -}; - -exports.fetch = function (cacheExpirationSeconds, success, error) { - var args = []; - if (typeof cacheExpirationSeconds === 'number') { - args.push(cacheExpirationSeconds); - } else { - error = success; - success = cacheExpirationSeconds; - } - exec(success, error, "FirebasePlugin", "fetch", args); -}; - -exports.getByteArray = function (key, namespace, success, error) { - var args = [key]; - if (typeof namespace === 'string') { - args.push(namespace); - } else { - error = success; - success = namespace; - } - exec(success, error, "FirebasePlugin", "getByteArray", args); -}; - -exports.getValue = function (key, namespace, success, error) { - var args = [key]; - if (typeof namespace === 'string') { - args.push(namespace); - } else { - error = success; - success = namespace; - } - exec(success, error, "FirebasePlugin", "getValue", args); -}; - -exports.getInfo = function (success, error) { - exec(success, error, "FirebasePlugin", "getInfo", []); -}; - -exports.setConfigSettings = function (settings, success, error) { - exec(success, error, "FirebasePlugin", "setConfigSettings", [settings]); -}; - -exports.setDefaults = function (defaults, namespace, success, error) { - var args = [defaults]; - if (typeof namespace === 'string') { - args.push(namespace); - } else { - error = success; - success = namespace; - } - exec(success, error, "FirebasePlugin", "setDefaults", args); -}; - -}); diff --git a/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-push/www/push.js b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-push/www/push.js index a5315486..7234d474 100644 --- a/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-push/www/push.js +++ b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-push/www/push.js @@ -1,4 +1,16 @@ cordova.define("phonegap-plugin-push.PushNotification", function(require, exports, module) { +/** +* This file has been generated by Babel. +* +* DO NOT EDIT IT DIRECTLY +* +* Edit the JS source file src/js/push.js +**/'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + /* global cordova:false */ /* globals window */ @@ -8,322 +20,358 @@ cordova.define("phonegap-plugin-push.PushNotification", function(require, export var exec = cordova.require('cordova/exec'); -/** - * PushNotification constructor. - * - * @param {Object} options to initiate Push Notifications. - * @return {PushNotification} instance that can be monitored and cancelled. - */ +var PushNotification = function () { + /** + * PushNotification constructor. + * + * @param {Object} options to initiate Push Notifications. + * @return {PushNotification} instance that can be monitored and cancelled. + */ + function PushNotification(options) { + var _this = this; + + _classCallCheck(this, PushNotification); -var PushNotification = function(options) { - this._handlers = { - 'registration': [], - 'notification': [], - 'error': [] + this.handlers = { + registration: [], + notification: [], + error: [] }; // require options parameter if (typeof options === 'undefined') { - throw new Error('The options argument is required.'); + throw new Error('The options argument is required.'); } // store the options to this object instance this.options = options; // triggered on registration and notification - var that = this; - var success = function(result) { - if (result && typeof result.registrationId !== 'undefined') { - that.emit('registration', result); - } else if (result && result.additionalData && typeof result.additionalData.actionCallback !== 'undefined') { - var executeFuctionOrEmitEventByName = function(callbackName, context, arg) { - var namespaces = callbackName.split('.'); - var func = namespaces.pop(); - for (var i = 0; i < namespaces.length; i++) { - context = context[namespaces[i]]; - } + var success = function success(result) { + if (result && typeof result.registrationId !== 'undefined') { + _this.emit('registration', result); + } else if (result && result.additionalData && typeof result.additionalData.actionCallback !== 'undefined') { + var executeFuctionOrEmitEventByName = function executeFuctionOrEmitEventByName(functionName, context) { + for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } - if (typeof context[func] === 'function') { - context[func].call(context, arg); - } else { - that.emit(callbackName, arg); - } - }; + var namespaces = functionName.split('.'); + var func = namespaces.pop(); + for (var i = 0; i < namespaces.length; i++) { + context = context[namespaces[i]]; + } - executeFuctionOrEmitEventByName(result.additionalData.actionCallback, window, result); - } else if (result) { - that.emit('notification', result); - } + if (typeof context[func] === 'function') { + context[func].call(context, args); + } else { + _this.emit(functionName, args); + } + }; + + executeFuctionOrEmitEventByName(result.additionalData.actionCallback, window, result); + } else if (result) { + _this.emit('notification', result); + } }; // triggered on error - var fail = function(msg) { - var e = (typeof msg === 'string') ? new Error(msg) : msg; - that.emit('error', e); + var fail = function fail(msg) { + var e = typeof msg === 'string' ? new Error(msg) : msg; + _this.emit('error', e); }; // wait at least one process tick to allow event subscriptions - setTimeout(function() { - exec(success, fail, 'PushNotification', 'init', [options]); + setTimeout(function () { + exec(success, fail, 'PushNotification', 'init', [options]); }, 10); -}; + } + + /** + * Unregister from push notifications + */ -/** - * Unregister from push notifications - */ -PushNotification.prototype.unregister = function(successCallback, errorCallback, options) { - if (!errorCallback) { errorCallback = function() {}; } + _createClass(PushNotification, [{ + key: 'unregister', + value: function unregister(successCallback) { + var _this2 = this; - if (typeof errorCallback !== 'function') { + var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; + var options = arguments[2]; + + if (typeof errorCallback !== 'function') { console.log('PushNotification.unregister failure: failure parameter not a function'); return; - } + } - if (typeof successCallback !== 'function') { - console.log('PushNotification.unregister failure: success callback parameter must be a function'); + if (typeof successCallback !== 'function') { + console.log('PushNotification.unregister failure: success callback parameter ' + ' must be a function'); return; - } + } - var that = this; - var cleanHandlersAndPassThrough = function() { + var cleanHandlersAndPassThrough = function cleanHandlersAndPassThrough() { if (!options) { - that._handlers = { - 'registration': [], - 'notification': [], - 'error': [] - }; + _this2.handlers = { + registration: [], + notification: [], + error: [] + }; } successCallback(); - }; + }; - exec(cleanHandlersAndPassThrough, errorCallback, 'PushNotification', 'unregister', [options]); -}; + exec(cleanHandlersAndPassThrough, errorCallback, 'PushNotification', 'unregister', [options]); + } -/** - * subscribe to a topic - * @param {String} topic topic to subscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ -PushNotification.prototype.subscribe = function(topic, successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } + /** + * subscribe to a topic + * @param {String} topic topic to subscribe + * @param {Function} successCallback success callback + * @param {Function} errorCallback error callback + * @return {void} + */ + + }, { + key: 'subscribe', + value: function subscribe(topic, successCallback) { + var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; - if (typeof errorCallback !== 'function') { - console.log('PushNotification.subscribe failure: failure parameter not a function'); + if (typeof errorCallback !== 'function') { + console.log('PushNotification.subscribe failure: ' + 'failure parameter not a function'); return; - } + } - if (typeof successCallback !== 'function') { - console.log('PushNotification.subscribe failure: success callback parameter must be a function'); + if (typeof successCallback !== 'function') { + console.log('PushNotification.subscribe failure: ' + 'success callback parameter must be a function'); return; + } + + exec(successCallback, errorCallback, 'PushNotification', 'subscribe', [topic]); } - exec(successCallback, errorCallback, 'PushNotification', 'subscribe', [topic]); -}; + /** + * unsubscribe to a topic + * @param {String} topic topic to unsubscribe + * @param {Function} successCallback success callback + * @param {Function} errorCallback error callback + * @return {void} + */ -/** - * unsubscribe to a topic - * @param {String} topic topic to unsubscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ -PushNotification.prototype.unsubscribe = function(topic, successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } + }, { + key: 'unsubscribe', + value: function unsubscribe(topic, successCallback) { + var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; - if (typeof errorCallback !== 'function') { + if (typeof errorCallback !== 'function') { console.log('PushNotification.unsubscribe failure: failure parameter not a function'); return; - } + } - if (typeof successCallback !== 'function') { - console.log('PushNotification.unsubscribe failure: success callback parameter must be a function'); + if (typeof successCallback !== 'function') { + console.log('PushNotification.unsubscribe failure: ' + 'success callback parameter must be a function'); return; - } + } - exec(successCallback, errorCallback, 'PushNotification', 'unsubscribe', [topic]); -}; + exec(successCallback, errorCallback, 'PushNotification', 'unsubscribe', [topic]); + } -/** - * Call this to set the application icon badge - */ + /** + * Call this to set the application icon badge + */ -PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) { - if (!errorCallback) { errorCallback = function() {}; } + }, { + key: 'setApplicationIconBadgeNumber', + value: function setApplicationIconBadgeNumber(successCallback) { + var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; + var badge = arguments[2]; - if (typeof errorCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function'); + if (typeof errorCallback !== 'function') { + console.log('PushNotification.setApplicationIconBadgeNumber failure: failure ' + 'parameter not a function'); return; - } + } - if (typeof successCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function'); + if (typeof successCallback !== 'function') { + console.log('PushNotification.setApplicationIconBadgeNumber failure: success ' + 'callback parameter must be a function'); return; - } + } - exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{badge: badge}]); -}; + exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{ badge: badge }]); + } -/** - * Get the application icon badge - */ + /** + * Get the application icon badge + */ -PushNotification.prototype.getApplicationIconBadgeNumber = function(successCallback, errorCallback) { - if (!errorCallback) { errorCallback = function() {}; } + }, { + key: 'getApplicationIconBadgeNumber', + value: function getApplicationIconBadgeNumber(successCallback) { + var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; - if (typeof errorCallback !== 'function') { - console.log('PushNotification.getApplicationIconBadgeNumber failure: failure parameter not a function'); + if (typeof errorCallback !== 'function') { + console.log('PushNotification.getApplicationIconBadgeNumber failure: failure ' + 'parameter not a function'); return; - } + } - if (typeof successCallback !== 'function') { - console.log('PushNotification.getApplicationIconBadgeNumber failure: success callback parameter must be a function'); + if (typeof successCallback !== 'function') { + console.log('PushNotification.getApplicationIconBadgeNumber failure: success ' + 'callback parameter must be a function'); return; - } + } - exec(successCallback, errorCallback, 'PushNotification', 'getApplicationIconBadgeNumber', []); -}; + exec(successCallback, errorCallback, 'PushNotification', 'getApplicationIconBadgeNumber', []); + } -/** - * Get the application icon badge - */ + /** + * Clear all notifications + */ -PushNotification.prototype.clearAllNotifications = function(successCallback, errorCallback) { - if (!successCallback) { successCallback = function() {}; } - if (!errorCallback) { errorCallback = function() {}; } + }, { + key: 'clearAllNotifications', + value: function clearAllNotifications() { + var successCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {}; + var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; - if (typeof errorCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: failure parameter not a function'); + if (typeof errorCallback !== 'function') { + console.log('PushNotification.clearAllNotifications failure: failure parameter ' + 'not a function'); return; - } + } - if (typeof successCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: success callback parameter must be a function'); + if (typeof successCallback !== 'function') { + console.log('PushNotification.clearAllNotifications failure: success callback ' + 'parameter must be a function'); return; - } + } - exec(successCallback, errorCallback, 'PushNotification', 'clearAllNotifications', []); -}; - -/** - * Listen for an event. - * - * Any event is supported, but the following are built-in: - * - * - registration - * - notification - * - error - * - * @param {String} eventName to subscribe to. - * @param {Function} callback triggered on the event. - */ + exec(successCallback, errorCallback, 'PushNotification', 'clearAllNotifications', []); + } + /** + * Listen for an event. + * + * The following events are supported: + * + * - registration + * - notification + * - error + * + * @param {String} eventName to subscribe to. + * @param {Function} callback triggered on the event. + */ -PushNotification.prototype.on = function(eventName, callback) { - if (!this._handlers.hasOwnProperty(eventName)) { - this._handlers[eventName] = []; + }, { + key: 'on', + value: function on(eventName, callback) { + if (!this.handlers.hasOwnProperty(eventName)) { + this.handlers[eventName] = []; + } + this.handlers[eventName].push(callback); } - this._handlers[eventName].push(callback); -}; -/** - * Remove event listener. - * - * @param {String} eventName to match subscription. - * @param {Function} handle function associated with event. - */ + /** + * Remove event listener. + * + * @param {String} eventName to match subscription. + * @param {Function} handle function associated with event. + */ -PushNotification.prototype.off = function (eventName, handle) { - if (this._handlers.hasOwnProperty(eventName)) { - var handleIndex = this._handlers[eventName].indexOf(handle); + }, { + key: 'off', + value: function off(eventName, handle) { + if (this.handlers.hasOwnProperty(eventName)) { + var handleIndex = this.handlers[eventName].indexOf(handle); if (handleIndex >= 0) { - this._handlers[eventName].splice(handleIndex, 1); + this.handlers[eventName].splice(handleIndex, 1); } + } } -}; -/** - * Emit an event. - * - * This is intended for internal use only. - * - * @param {String} eventName is the event to trigger. - * @param {*} all arguments are passed to the event listeners. - * - * @return {Boolean} is true when the event is triggered otherwise false. - */ + /** + * Emit an event. + * + * This is intended for internal use only. + * + * @param {String} eventName is the event to trigger. + * @param {*} all arguments are passed to the event listeners. + * + * @return {Boolean} is true when the event is triggered otherwise false. + */ -PushNotification.prototype.emit = function() { - var args = Array.prototype.slice.call(arguments); - var eventName = args.shift(); + }, { + key: 'emit', + value: function emit() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - if (!this._handlers.hasOwnProperty(eventName)) { + var eventName = args.shift(); + + if (!this.handlers.hasOwnProperty(eventName)) { return false; - } + } - for (var i = 0, length = this._handlers[eventName].length; i < length; i++) { - var callback = this._handlers[eventName][i]; + for (var i = 0, length = this.handlers[eventName].length; i < length; i++) { + var callback = this.handlers[eventName][i]; if (typeof callback === 'function') { - callback.apply(undefined,args); + callback.apply(undefined, args); } else { - console.log('event handler: ' + eventName + ' must be a function'); + console.log('event handler: ' + eventName + ' must be a function'); } - } + } - return true; -}; - -PushNotification.prototype.finish = function(successCallback, errorCallback, id) { - if (!successCallback) { successCallback = function() {}; } - if (!errorCallback) { errorCallback = function() {}; } - if (!id) { id = 'handler'; } + return true; + } + }, { + key: 'finish', + value: function finish() { + var successCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {}; + var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; + var id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'handler'; - if (typeof successCallback !== 'function') { + if (typeof successCallback !== 'function') { console.log('finish failure: success callback parameter must be a function'); return; - } + } - if (typeof errorCallback !== 'function') { + if (typeof errorCallback !== 'function') { console.log('finish failure: failure parameter not a function'); return; + } + + exec(successCallback, errorCallback, 'PushNotification', 'finish', [id]); } + }]); - exec(successCallback, errorCallback, 'PushNotification', 'finish', [id]); -}; + return PushNotification; +}(); /*! * Push Notification Plugin. */ module.exports = { - /** - * Register for Push Notifications. - * - * This method will instantiate a new copy of the PushNotification object - * and start the registration process. - * - * @param {Object} options - * @return {PushNotification} instance - */ - - init: function(options) { - return new PushNotification(options); - }, + /** + * Register for Push Notifications. + * + * This method will instantiate a new copy of the PushNotification object + * and start the registration process. + * + * @param {Object} options + * @return {PushNotification} instance + */ - hasPermission: function(successCallback, errorCallback) { - exec(successCallback, errorCallback, 'PushNotification', 'hasPermission', []); - }, + init: function init(options) { + return new PushNotification(options); + }, - /** - * PushNotification Object. - * - * Expose the PushNotification object for direct use - * and testing. Typically, you should use the - * .init helper method. - */ + hasPermission: function hasPermission(successCallback, errorCallback) { + exec(successCallback, errorCallback, 'PushNotification', 'hasPermission', []); + }, - PushNotification: PushNotification + /** + * PushNotification Object. + * + * Expose the PushNotification object for direct use + * and testing. Typically, you should use the + * .init helper method. + */ + PushNotification: PushNotification }; - }); |
