From 8dae6a5044f9c1b7a8497cc1c96155fd262b40cf Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 26 Oct 2017 01:41:16 +0200 Subject: iphone x fixes --- .../www/console-via-logger.js | 189 -------- .../plugins/cordova-plugin-console/www/logger.js | 357 --------------- .../src/www/ios/ios-wkwebview-exec.js | 179 -------- .../www/plugins/phonegap-plugin-push/www/push.js | 496 ++++++++++----------- 4 files changed, 224 insertions(+), 997 deletions(-) delete mode 100644 StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/console-via-logger.js delete mode 100644 StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/logger.js delete mode 100644 StoneIsland/platforms/ios/www/plugins/cordova-plugin-wkwebview-engine/src/www/ios/ios-wkwebview-exec.js (limited to 'StoneIsland/platforms/ios/www/plugins') diff --git a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/console-via-logger.js b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/console-via-logger.js deleted file mode 100644 index 0ecd9cc3..00000000 --- a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/console-via-logger.js +++ /dev/null @@ -1,189 +0,0 @@ -cordova.define("cordova-plugin-console.console", function(require, exports, module) { -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -//------------------------------------------------------------------------------ - -var logger = require("./logger"); - -//------------------------------------------------------------------------------ -// object that we're exporting -//------------------------------------------------------------------------------ -var console = module.exports; - -//------------------------------------------------------------------------------ -// copy of the original console object -//------------------------------------------------------------------------------ -var WinConsole = window.console; - -//------------------------------------------------------------------------------ -// whether to use the logger -//------------------------------------------------------------------------------ -var UseLogger = false; - -//------------------------------------------------------------------------------ -// Timers -//------------------------------------------------------------------------------ -var Timers = {}; - -//------------------------------------------------------------------------------ -// used for unimplemented methods -//------------------------------------------------------------------------------ -function noop() {} - -//------------------------------------------------------------------------------ -// used for unimplemented methods -//------------------------------------------------------------------------------ -console.useLogger = function (value) { - if (arguments.length) UseLogger = !!value; - - if (UseLogger) { - if (logger.useConsole()) { - throw new Error("console and logger are too intertwingly"); - } - } - - return UseLogger; -}; - -//------------------------------------------------------------------------------ -console.log = function() { - if (logger.useConsole()) return; - logger.log.apply(logger, [].slice.call(arguments)); -}; - -//------------------------------------------------------------------------------ -console.error = function() { - if (logger.useConsole()) return; - logger.error.apply(logger, [].slice.call(arguments)); -}; - -//------------------------------------------------------------------------------ -console.warn = function() { - if (logger.useConsole()) return; - logger.warn.apply(logger, [].slice.call(arguments)); -}; - -//------------------------------------------------------------------------------ -console.info = function() { - if (logger.useConsole()) return; - logger.info.apply(logger, [].slice.call(arguments)); -}; - -//------------------------------------------------------------------------------ -console.debug = function() { - if (logger.useConsole()) return; - logger.debug.apply(logger, [].slice.call(arguments)); -}; - -//------------------------------------------------------------------------------ -console.assert = function(expression) { - if (expression) return; - - var message = logger.format.apply(logger.format, [].slice.call(arguments, 1)); - console.log("ASSERT: " + message); -}; - -//------------------------------------------------------------------------------ -console.clear = function() {}; - -//------------------------------------------------------------------------------ -console.dir = function(object) { - console.log("%o", object); -}; - -//------------------------------------------------------------------------------ -console.dirxml = function(node) { - console.log(node.innerHTML); -}; - -//------------------------------------------------------------------------------ -console.trace = noop; - -//------------------------------------------------------------------------------ -console.group = console.log; - -//------------------------------------------------------------------------------ -console.groupCollapsed = console.log; - -//------------------------------------------------------------------------------ -console.groupEnd = noop; - -//------------------------------------------------------------------------------ -console.time = function(name) { - Timers[name] = new Date().valueOf(); -}; - -//------------------------------------------------------------------------------ -console.timeEnd = function(name) { - var timeStart = Timers[name]; - if (!timeStart) { - console.warn("unknown timer: " + name); - return; - } - - var timeElapsed = new Date().valueOf() - timeStart; - console.log(name + ": " + timeElapsed + "ms"); -}; - -//------------------------------------------------------------------------------ -console.timeStamp = noop; - -//------------------------------------------------------------------------------ -console.profile = noop; - -//------------------------------------------------------------------------------ -console.profileEnd = noop; - -//------------------------------------------------------------------------------ -console.count = noop; - -//------------------------------------------------------------------------------ -console.exception = console.log; - -//------------------------------------------------------------------------------ -console.table = function(data, columns) { - console.log("%o", data); -}; - -//------------------------------------------------------------------------------ -// return a new function that calls both functions passed as args -//------------------------------------------------------------------------------ -function wrappedOrigCall(orgFunc, newFunc) { - return function() { - var args = [].slice.call(arguments); - try { orgFunc.apply(WinConsole, args); } catch (e) {} - try { newFunc.apply(console, args); } catch (e) {} - }; -} - -//------------------------------------------------------------------------------ -// For every function that exists in the original console object, that -// also exists in the new console object, wrap the new console method -// with one that calls both -//------------------------------------------------------------------------------ -for (var key in console) { - if (typeof WinConsole[key] == "function") { - console[key] = wrappedOrigCall(WinConsole[key], console[key]); - } -} - -}); diff --git a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/logger.js b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/logger.js deleted file mode 100644 index deb07b57..00000000 --- a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-console/www/logger.js +++ /dev/null @@ -1,357 +0,0 @@ -cordova.define("cordova-plugin-console.logger", function(require, exports, module) { -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -//------------------------------------------------------------------------------ -// The logger module exports the following properties/functions: -// -// LOG - constant for the level LOG -// ERROR - constant for the level ERROR -// WARN - constant for the level WARN -// INFO - constant for the level INFO -// DEBUG - constant for the level DEBUG -// logLevel() - returns current log level -// logLevel(value) - sets and returns a new log level -// useConsole() - returns whether logger is using console -// useConsole(value) - sets and returns whether logger is using console -// log(message,...) - logs a message at level LOG -// error(message,...) - logs a message at level ERROR -// warn(message,...) - logs a message at level WARN -// info(message,...) - logs a message at level INFO -// debug(message,...) - logs a message at level DEBUG -// logLevel(level,message,...) - logs a message specified level -// -//------------------------------------------------------------------------------ - -var logger = exports; - -var exec = require('cordova/exec'); - -var UseConsole = false; -var UseLogger = true; -var Queued = []; -var DeviceReady = false; -var CurrentLevel; - -var originalConsole = console; - -/** - * Logging levels - */ - -var Levels = [ - "LOG", - "ERROR", - "WARN", - "INFO", - "DEBUG" -]; - -/* - * add the logging levels to the logger object and - * to a separate levelsMap object for testing - */ - -var LevelsMap = {}; -for (var i=0; i 0){ - formatArgs.unshift(fmtString); // add formatString - } - - var message = logger.format.apply(logger.format, formatArgs); - - if (LevelsMap[level] === null) { - throw new Error("invalid logging level: " + level); - } - - if (LevelsMap[level] > CurrentLevel) return; - - // queue the message if not yet at deviceready - if (!DeviceReady && !UseConsole) { - Queued.push([level, message]); - return; - } - - // Log using the native logger if that is enabled - if (UseLogger) { - exec(null, null, "Console", "logLevel", [level, message]); - } - - // Log using the console if that is enabled - if (UseConsole) { - // make sure console is not using logger - if (console.useLogger()) { - throw new Error("console and logger are too intertwingly"); - } - - // log to the console - switch (level) { - case logger.LOG: originalConsole.log(message); break; - case logger.ERROR: originalConsole.log("ERROR: " + message); break; - case logger.WARN: originalConsole.log("WARN: " + message); break; - case logger.INFO: originalConsole.log("INFO: " + message); break; - case logger.DEBUG: originalConsole.log("DEBUG: " + message); break; - } - } -}; - - -/** - * Formats a string and arguments following it ala console.log() - * - * Any remaining arguments will be appended to the formatted string. - * - * for rationale, see FireBug's Console API: - * http://getfirebug.com/wiki/index.php/Console_API - */ -logger.format = function(formatString, args) { - return __format(arguments[0], [].slice.call(arguments,1)).join(' '); -}; - - -//------------------------------------------------------------------------------ -/** - * Formats a string and arguments following it ala vsprintf() - * - * format chars: - * %j - format arg as JSON - * %o - format arg as JSON - * %c - format arg as '' - * %% - replace with '%' - * any other char following % will format it's - * arg via toString(). - * - * Returns an array containing the formatted string and any remaining - * arguments. - */ -function __format(formatString, args) { - if (formatString === null || formatString === undefined) return [""]; - if (arguments.length == 1) return [formatString.toString()]; - - if (typeof formatString != "string") - formatString = formatString.toString(); - - var pattern = /(.*?)%(.)(.*)/; - var rest = formatString; - var result = []; - - while (args.length) { - var match = pattern.exec(rest); - if (!match) break; - - var arg = args.shift(); - rest = match[3]; - result.push(match[1]); - - if (match[2] == '%') { - result.push('%'); - args.unshift(arg); - continue; - } - - result.push(__formatted(arg, match[2])); - } - - result.push(rest); - - var remainingArgs = [].slice.call(args); - remainingArgs.unshift(result.join('')); - return remainingArgs; -} - -function __formatted(object, formatChar) { - - try { - switch(formatChar) { - case 'j': - case 'o': return JSON.stringify(object); - case 'c': return ''; - } - } - catch (e) { - return "error JSON.stringify()ing argument: " + e; - } - - if ((object === null) || (object === undefined)) { - return Object.prototype.toString.call(object); - } - - return object.toString(); -} - - -//------------------------------------------------------------------------------ -// when deviceready fires, log queued messages -logger.__onDeviceReady = function() { - if (DeviceReady) return; - - DeviceReady = true; - - for (var i=0; i 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; - } - - var namespaces = functionName.split('.'); - var func = namespaces.pop(); - for (var i = 0; i < namespaces.length; i++) { - context = context[namespaces[i]]; - } - - 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); - } + 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]]; + } + + if (typeof context[func] === 'function') { + context[func].call(context, arg); + } else { + that.emit(callbackName, arg); + } + }; + + executeFuctionOrEmitEventByName(result.additionalData.actionCallback, window, result); + } else if (result) { + that.emit('notification', result); + } }; // triggered on error - var fail = function fail(msg) { - var e = typeof msg === 'string' ? new Error(msg) : msg; - _this.emit('error', e); + var fail = function(msg) { + var e = (typeof msg === 'string') ? new Error(msg) : msg; + that.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 - */ - +}; - _createClass(PushNotification, [{ - key: 'unregister', - value: function unregister(successCallback) { - var _this2 = this; +/** + * Unregister from push notifications + */ - var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; - var options = arguments[2]; +PushNotification.prototype.unregister = function(successCallback, errorCallback, options) { + if (!errorCallback) { errorCallback = function() {}; } - if (typeof errorCallback !== 'function') { + 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 cleanHandlersAndPassThrough = function cleanHandlersAndPassThrough() { + var that = this; + var cleanHandlersAndPassThrough = function() { if (!options) { - _this2.handlers = { - registration: [], - notification: [], - error: [] - }; + that._handlers = { + 'registration': [], + 'notification': [], + 'error': [] + }; } successCallback(); - }; - - 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} - */ + exec(cleanHandlersAndPassThrough, errorCallback, 'PushNotification', 'unregister', [options]); +}; - }, { - key: 'subscribe', - value: function subscribe(topic, successCallback) { - var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; +/** + * 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() {}; } - 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]); } - /** - * unsubscribe to a topic - * @param {String} topic topic to unsubscribe - * @param {Function} successCallback success callback - * @param {Function} errorCallback error callback - * @return {void} - */ + exec(successCallback, errorCallback, 'PushNotification', 'subscribe', [topic]); +}; - }, { - key: 'unsubscribe', - value: function unsubscribe(topic, successCallback) { - var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {}; +/** + * 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() {}; } - 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]); } - /** - * Call this to set the application icon badge - */ + exec(successCallback, errorCallback, 'PushNotification', 'unsubscribe', [topic]); +}; - }, { - key: 'setApplicationIconBadgeNumber', - value: function setApplicationIconBadgeNumber(successCallback) { - var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; - var badge = arguments[2]; +/** + * Call this to set the application icon badge + */ - if (typeof errorCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: failure ' + 'parameter not a function'); - return; - } +PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) { + if (!errorCallback) { errorCallback = function() {}; } - if (typeof successCallback !== 'function') { - console.log('PushNotification.setApplicationIconBadgeNumber failure: success ' + 'callback parameter must be a function'); + if (typeof errorCallback !== 'function') { + console.log('PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function'); return; - } + } - exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{ badge: badge }]); + if (typeof successCallback !== 'function') { + console.log('PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function'); + return; } - /** - * Get the application icon badge - */ + exec(successCallback, errorCallback, 'PushNotification', 'setApplicationIconBadgeNumber', [{badge: badge}]); +}; + +/** + * Get the application icon badge + */ - }, { - key: 'getApplicationIconBadgeNumber', - value: function getApplicationIconBadgeNumber(successCallback) { - var errorCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; +PushNotification.prototype.getApplicationIconBadgeNumber = function(successCallback, errorCallback) { + if (!errorCallback) { errorCallback = 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', []); } - /** - * Clear all notifications - */ + exec(successCallback, errorCallback, 'PushNotification', 'getApplicationIconBadgeNumber', []); +}; - }, { - 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 () {}; +/** + * Get the application icon badge + */ - if (typeof errorCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: failure parameter ' + 'not a function'); - return; - } +PushNotification.prototype.clearAllNotifications = function(successCallback, errorCallback) { + if (!successCallback) { successCallback = function() {}; } + if (!errorCallback) { errorCallback = function() {}; } - if (typeof successCallback !== 'function') { - console.log('PushNotification.clearAllNotifications failure: success callback ' + 'parameter must be a function'); + if (typeof errorCallback !== 'function') { + console.log('PushNotification.clearAllNotifications failure: failure parameter not a function'); return; - } + } - exec(successCallback, errorCallback, 'PushNotification', 'clearAllNotifications', []); + if (typeof successCallback !== 'function') { + console.log('PushNotification.clearAllNotifications failure: success callback parameter must be a function'); + return; } - /** - * 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. - */ - }, { - key: 'on', - value: function on(eventName, callback) { - if (!this.handlers.hasOwnProperty(eventName)) { - this.handlers[eventName] = []; - } - this.handlers[eventName].push(callback); + 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. + */ + +PushNotification.prototype.on = function(eventName, callback) { + if (!this._handlers.hasOwnProperty(eventName)) { + this._handlers[eventName] = []; } + 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. + */ - }, { - key: 'off', - value: function off(eventName, handle) { - if (this.handlers.hasOwnProperty(eventName)) { - var handleIndex = this.handlers[eventName].indexOf(handle); +PushNotification.prototype.off = function (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. - */ - - }, { - key: 'emit', - value: function emit() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } +/** + * 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. + */ - var eventName = args.shift(); +PushNotification.prototype.emit = function() { + var args = Array.prototype.slice.call(arguments); + var eventName = args.shift(); - if (!this.handlers.hasOwnProperty(eventName)) { + 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; } - }, { - 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') { + + return true; +}; + +PushNotification.prototype.finish = function(successCallback, errorCallback, id) { + if (!successCallback) { successCallback = function() {}; } + if (!errorCallback) { errorCallback = function() {}; } + if (!id) { id = 'handler'; } + + 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]); } - }]); - return PushNotification; -}(); + exec(successCallback, errorCallback, 'PushNotification', 'finish', [id]); +}; /*! * 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 init(options) { - return new PushNotification(options); - }, - - hasPermission: function hasPermission(successCallback, errorCallback) { - exec(successCallback, errorCallback, 'PushNotification', 'hasPermission', []); - }, - - /** - * PushNotification Object. - * - * Expose the PushNotification object for direct use - * and testing. Typically, you should use the - * .init helper method. - */ - PushNotification: PushNotification + /** + * 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); + }, + + hasPermission: function(successCallback, errorCallback) { + exec(successCallback, errorCallback, 'PushNotification', 'hasPermission', []); + }, + + /** + * PushNotification Object. + * + * Expose the PushNotification object for direct use + * and testing. Typically, you should use the + * .init helper method. + */ + + PushNotification: PushNotification }; + }); -- cgit v1.2.3-70-g09d2