From 7f27d97633f9ee8ce2da8ce3291ef923c91cb921 Mon Sep 17 00:00:00 2001 From: Jmdma23 <56601964+Jmdma23@users.noreply.github.com> Date: Tue, 15 Oct 2019 17:32:09 +0100 Subject: [PATCH 1/2] Add files via upload --- www/local-notification-core.js | 507 +++++++++++++++++++++++++++++++++ www/local-notification-util.js | 325 +++++++++++++++++++++ 2 files changed, 832 insertions(+) create mode 100644 www/local-notification-core.js create mode 100644 www/local-notification-util.js diff --git a/www/local-notification-core.js b/www/local-notification-core.js new file mode 100644 index 000000000..afcc24575 --- /dev/null +++ b/www/local-notification-core.js @@ -0,0 +1,507 @@ +/* + * Copyright (c) 2013-2015 by appPlant UG. All rights reserved. + * + * @APPPLANT_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apache License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://opensource.org/licenses/Apache-2.0/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPPLANT_LICENSE_HEADER_END@ + */ + +var exec = require('cordova/exec'); + + +/******** + * CORE * + ********/ + +/** + * Returns the default settings. + * + * @return {Object} + */ +exports.getDefaults = function () { + return this._defaults; +}; + +/** + * Overwrite default settings. + * + * @param {Object} defaults + */ +exports.setDefaults = function (newDefaults) { + var defaults = this.getDefaults(); + + for (var key in defaults) { + if (newDefaults.hasOwnProperty(key)) { + defaults[key] = newDefaults[key]; + } + } +}; + +/** + * Schedule a new local notification. + * + * @param {Object} msgs + * The notification properties + * @param {Function} callback + * A function to be called after the notification has been canceled + * @param {Object?} scope + * The scope for the callback function + * @param {Object?} args + * skipPermission:true schedules the notifications immediatly without + * registering or checking for permission + */ +exports.schedule = function (msgs, callback, scope, args) { + var fn = function(granted) { + + if (!granted) return; + + var notifications = Array.isArray(msgs) ? msgs : [msgs]; + + for (var i = 0; i < notifications.length; i++) { + var notification = notifications[i]; + + this.mergeWithDefaults(notification); + this.convertProperties(notification); + } + + this.exec('schedule', notifications, callback, scope); + }; + + if (args && args.skipPermission) { + fn.call(this, true); + } else { + this.registerPermission(fn, this); + } +}; + +/** + * Update existing notifications specified by IDs in options. + * + * @param {Object} notifications + * The notification properties to update + * @param {Function} callback + * A function to be called after the notification has been updated + * @param {Object?} scope + * The scope for the callback function + * @param {Object?} args + * skipPermission:true schedules the notifications immediatly without + * registering or checking for permission + */ +exports.update = function (msgs, callback, scope, args) { + var fn = function(granted) { + + if (!granted) return; + + var notifications = Array.isArray(msgs) ? msgs : [msgs]; + + for (var i = 0; i < notifications.length; i++) { + var notification = notifications[i]; + + this.convertProperties(notification); + } + + this.exec('update', notifications, callback, scope); + }; + + if (args && args.skipPermission) { + fn.call(this, true); + } else { + this.registerPermission(fn, this); + } +}; + +/** + * Clear the specified notification. + * + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A function to be called after the notification has been cleared + * @param {Object?} scope + * The scope for the callback function + */ +exports.clear = function (ids, callback, scope) { + ids = Array.isArray(ids) ? ids : [ids]; + ids = this.convertIds(ids); + + this.exec('clear', ids, callback, scope); +}; + +/** + * Clear all previously sheduled notifications. + * + * @param {Function} callback + * A function to be called after all notifications have been cleared + * @param {Object?} scope + * The scope for the callback function + */ +exports.clearAll = function (callback, scope) { + this.exec('clearAll', null, callback, scope); +}; + +/** + * Cancel the specified notifications. + * + * @param {String[]} ids + * The IDs of the notifications + * @param {Function} callback + * A function to be called after the notifications has been canceled + * @param {Object?} scope + * The scope for the callback function + */ +exports.cancel = function (ids, callback, scope) { + ids = Array.isArray(ids) ? ids : [ids]; + ids = this.convertIds(ids); + + this.exec('cancel', ids, callback, scope); +}; + +/** + * Remove all previously registered notifications. + * + * @param {Function} callback + * A function to be called after all notifications have been canceled + * @param {Object?} scope + * The scope for the callback function + */ +exports.cancelAll = function (callback, scope) { + this.exec('cancelAll', null, callback, scope); +}; + +/** + * Check if a notification with an ID is present. + * + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.isPresent = function (id, callback, scope) { + this.exec('isPresent', id || 0, callback, scope); +}; + +/** + * Check if a notification with an ID is scheduled. + * + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.isScheduled = function (id, callback, scope) { + this.exec('isScheduled', id || 0, callback, scope); +}; + +/** + * Check if a notification with an ID was triggered. + * + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.isTriggered = function (id, callback, scope) { + this.exec('isTriggered', id || 0, callback, scope); +}; + +/** + * List all local notification IDs. + * + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getAllIds = function (callback, scope) { + this.exec('getAllIds', null, callback, scope); +}; + +/** + * Alias for `getAllIds`. + */ +exports.getIds = function () { + this.getAllIds.apply(this, arguments); +}; + +/** + * List all scheduled notification IDs. + * + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getScheduledIds = function (callback, scope) { + this.exec('getScheduledIds', null, callback, scope); +}; + +/** + * List all triggered notification IDs. + * + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getTriggeredIds = function (callback, scope) { + this.exec('getTriggeredIds', null, callback, scope); +}; + +/** + * Property list for given local notifications. + * If called without IDs, all notification will be returned. + * + * @param {Number[]?} ids + * Set of notification IDs + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.get = function () { + var args = Array.apply(null, arguments); + + if (typeof args[0] == 'function') { + args.unshift([]); + } + + var ids = args[0], + callback = args[1], + scope = args[2]; + + if (!Array.isArray(ids)) { + this.exec('getSingle', Number(ids), callback, scope); + return; + } + + ids = this.convertIds(ids); + + this.exec('getAll', ids, callback, scope); +}; + +/** + * Property list for all local notifications. + * + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getAll = function (callback, scope) { + this.exec('getAll', null, callback, scope); +}; + +/** + * Property list for given scheduled notifications. + * If called without IDs, all notification will be returned. + * + * @param {Number[]?} ids + * Set of notification IDs + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getScheduled = function () { + var args = Array.apply(null, arguments); + + if (typeof args[0] == 'function') { + args.unshift([]); + } + + var ids = args[0], + callback = args[1], + scope = args[2]; + + if (!Array.isArray(ids)) { + ids = [ids]; + } + + if (!Array.isArray(ids)) { + this.exec('getSingleScheduled', Number(ids), callback, scope); + return; + } + + ids = this.convertIds(ids); + + this.exec('getScheduled', ids, callback, scope); +}; + +/** + * Property list for all scheduled notifications. + * + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getAllScheduled = function (callback, scope) { + this.exec('getScheduled', null, callback, scope); +}; + +/** + * Property list for given triggered notifications. + * If called without IDs, all notification will be returned. + * + * @param {Number[]?} ids + * Set of notification IDs + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getTriggered = function () { + var args = Array.apply(null, arguments); + + if (typeof args[0] == 'function') { + args.unshift([]); + } + + var ids = args[0], + callback = args[1], + scope = args[2]; + + if (!Array.isArray(ids)) { + ids = [ids]; + } + + if (!Array.isArray(ids)) { + this.exec('getSingleTriggered', Number(ids), callback, scope); + return; + } + + ids = this.convertIds(ids); + + this.exec('getTriggered', ids, callback, scope); +}; + +/** + * Property list for all triggered notifications. + * + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function + */ +exports.getAllTriggered = function (callback, scope) { + this.exec('getTriggered', null, callback, scope); +}; + +/** + * Informs if the app has the permission to show notifications. + * + * @param {Function} callback + * The function to be exec as the callback + * @param {Object?} scope + * The callback function's scope + */ +exports.hasPermission = function (callback, scope) { + var fn = this.createCallbackFn(callback, scope); + + if (device.platform != 'iOS') { + fn(true); + return; + } + + exec(fn, null, 'LocalNotification', 'hasPermission', []); +}; + +/** + * Register permission to show notifications if not already granted. + * + * @param {Function} callback + * The function to be exec as the callback + * @param {Object?} scope + * The callback function's scope + */ +exports.registerPermission = function (callback, scope) { + + if (this._registered) { + return this.hasPermission(callback, scope); + } else { + this._registered = true; + } + + var fn = this.createCallbackFn(callback, scope); + + if (device.platform != 'iOS') { + fn(true); + return; + } + + exec(fn, null, 'LocalNotification', 'registerPermission', []); +}; + + +/********** + * EVENTS * + **********/ + +/** + * Register callback for given event. + * + * @param {String} event + * The event's name + * @param {Function} callback + * The function to be exec as callback + * @param {Object?} scope + * The callback function's scope + */ +exports.on = function (event, callback, scope) { + + if (typeof callback !== "function") + return; + + if (!this._listener[event]) { + this._listener[event] = []; + } + + var item = [callback, scope || window]; + + this._listener[event].push(item); +}; + +/** + * Unregister callback for given event. + * + * @param {String} event + * The event's name + * @param {Function} callback + * The function to be exec as callback + */ +exports.un = function (event, callback) { + var listener = this._listener[event]; + + if (!listener) + return; + + for (var i = 0; i < listener.length; i++) { + var fn = listener[i][0]; + + if (fn == callback) { + listener.splice(i, 1); + break; + } + } +}; diff --git a/www/local-notification-util.js b/www/local-notification-util.js new file mode 100644 index 000000000..35e0fb5ca --- /dev/null +++ b/www/local-notification-util.js @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2013-2015 by appPlant UG. All rights reserved. + * + * @APPPLANT_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apache License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://opensource.org/licenses/Apache-2.0/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPPLANT_LICENSE_HEADER_END@ + */ + +var exec = require('cordova/exec'), + channel = require('cordova/channel'); + + +/*********** + * MEMBERS * + ***********/ + +// Default values +exports._defaults = { + text: '', + title: '', + sound: 'res://platform_default', + badge: 0, + id: 0, + data: undefined, + every: undefined, + at: undefined +}; + +// listener +exports._listener = {}; + +// Registered permission flag +exports._registered = false; + + +/******** + * UTIL * + ********/ + +/** + * Merge platform specific properties into the default ones. + * + * @return {Object} + * The default properties for the platform + */ +exports.applyPlatformSpecificOptions = function () { + var defaults = this._defaults; + + switch (device.platform) { + case 'Android': + defaults.icon = 'res://ic_popup_reminder'; + defaults.smallIcon = undefined; + defaults.ongoing = false; + defaults.autoClear = true; + defaults.led = undefined; + defaults.ledOnTime = undefined; + defaults.ledOffTime = undefined; + defaults.color = undefined; + break; + } + + return defaults; +}; + +/** + * Merge custom properties with the default values. + * + * @param {Object} options + * Set of custom values + * + * @retrun {Object} + * The merged property list + */ +exports.mergeWithDefaults = function (options) { + var defaults = this.getDefaults(); + + options.at = this.getValueFor(options, 'at', 'firstAt', 'date'); + options.text = this.getValueFor(options, 'text', 'message'); + options.data = this.getValueFor(options, 'data', 'json'); + + if (defaults.hasOwnProperty('autoClear')) { + options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel'); + } + + if (options.autoClear !== true && options.ongoing) { + options.autoClear = false; + } + + if (options.at === undefined || options.at === null) { + options.at = new Date(); + } + + for (var key in defaults) { + if (options[key] === null || options[key] === undefined) { + if (options.hasOwnProperty(key) && ['data','sound'].indexOf(key) > -1) { + options[key] = undefined; + } else { + options[key] = defaults[key]; + } + } + } + + for (key in options) { + if (!defaults.hasOwnProperty(key)) { + delete options[key]; + console.warn('Unknown property: ' + key); + } + } + + return options; +}; + +/** + * Convert the passed values to their required type. + * + * @param {Object} options + * Set of custom values + * + * @retrun {Object} + * The converted property list + */ +exports.convertProperties = function (options) { + + if (options.id) { + if (isNaN(options.id)) { + options.id = this.getDefaults().id; + console.warn('Id is not a number: ' + options.id); + } else { + options.id = Number(options.id); + } + } + + if (options.title) { + options.title = options.title.toString(); + } + + if (options.text) { + options.text = options.text.toString(); + } + + if (options.badge) { + if (isNaN(options.badge)) { + options.badge = this.getDefaults().badge; + console.warn('Badge number is not a number: ' + options.id); + } else { + options.badge = Number(options.badge); + } + } + + if (options.at) { + if (typeof options.at == 'object') { + options.at = options.at.getTime(); + } + else{ + if(isNaN(options.at)){ + try{ + options.at = new Date(options.at).getTime(); + } + catch(err){ + } + } + else{ + if(options.at.length == 10){ + options.at = options.at * 1000; + } + } + } + + options.at = Math.round(options.at/1000); + } + + if (typeof options.data == 'object') { + options.data = JSON.stringify(options.data); + } + + if (options.every) { + if (device.platform == 'iOS' && typeof options.every != 'string') { + options.every = this.getDefaults().every; + var warning = 'Every option is not a string: ' + options.id; + warning += '. Expects one of: second, minute, hour, day, week, '; + warning += 'month, year on iOS.'; + console.warn(warning); + } + } + + return options; +}; + +/** + * Create callback, which will be executed within a specific scope. + * + * @param {Function} callbackFn + * The callback function + * @param {Object} scope + * The scope for the function + * + * @return {Function} + * The new callback function + */ +exports.createCallbackFn = function (callbackFn, scope) { + + if (typeof callbackFn != 'function') + return; + + return function () { + callbackFn.apply(scope || this, arguments); + }; +}; + +/** + * Convert the IDs to numbers. + * + * @param {String/Number[]} ids + * + * @return Array of Numbers + */ +exports.convertIds = function (ids) { + var convertedIds = []; + + for (var i = 0; i < ids.length; i++) { + convertedIds.push(Number(ids[i])); + } + + return convertedIds; +}; + +/** + * First found value for the given keys. + * + * @param {Object} options + * Object with key-value properties + * @param {String[]} keys* + * Key list + */ +exports.getValueFor = function (options) { + var keys = Array.apply(null, arguments).slice(1); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + + if (options.hasOwnProperty(key)) { + return options[key]; + } + } +}; + +/** + * Fire event with given arguments. + * + * @param {String} event + * The event's name + * @param {args*} + * The callback's arguments + */ +exports.fireEvent = function (event) { + var args = Array.apply(null, arguments).slice(1), + listener = this._listener[event]; + + if (!listener) + return; + + for (var i = 0; i < listener.length; i++) { + var fn = listener[i][0], + scope = listener[i][1]; + + fn.apply(scope, args); + } +}; + +/** + * Execute the native counterpart. + * + * @param {String} action + * The name of the action + * @param args[] + * Array of arguments + * @param {Function} callback + * The callback function + * @param {Object} scope + * The scope for the function + */ +exports.exec = function (action, args, callback, scope) { + var fn = this.createCallbackFn(callback, scope), + params = []; + + if (Array.isArray(args)) { + params = args; + } else if (args) { + params.push(args); + } + + exec(fn, null, 'LocalNotification', action, params); +}; + +exports.deviceready = function() { + exec(null, null, 'LocalNotification', 'deviceready', []); +} + +/********* + * HOOKS * + *********/ + +// Called before 'deviceready' event +channel.onCordovaReady.subscribe(function () { + // Device plugin is ready now + channel.onCordovaInfoReady.subscribe(function () { + // Merge platform specifics into defaults + exports.applyPlatformSpecificOptions(); + }); +}); \ No newline at end of file From dc770ac003f23e17c7207b46ddf2c6af09ca1f87 Mon Sep 17 00:00:00 2001 From: Jmdma23 <56601964+Jmdma23@users.noreply.github.com> Date: Tue, 15 Oct 2019 17:35:07 +0100 Subject: [PATCH 2/2] Update local-notification.js --- www/local-notification.js | 1076 ++++++++----------------------------- 1 file changed, 211 insertions(+), 865 deletions(-) diff --git a/www/local-notification.js b/www/local-notification.js index 2e5176805..6dcabbf3a 100644 --- a/www/local-notification.js +++ b/www/local-notification.js @@ -1,7 +1,7 @@ /* - * Apache 2.0 License + * Copyright (c) 2013-2015 by appPlant UG. All rights reserved. * - * Copyright (c) Sebastian Katzer 2017 + * @APPPLANT_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apache License @@ -17,1020 +17,366 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. + * + * @APPPLANT_LICENSE_HEADER_END@ */ -var exec = require('cordova/exec'), - channel = require('cordova/channel'); - -// Defaults -exports._defaults = { - actions : [], - attachments : [], - autoClear : true, - badge : null, - channel : null, - clock : true, - color : null, - data : null, - defaults : 0, - foreground : null, - group : null, - groupSummary : false, - icon : null, - id : 0, - launch : true, - led : true, - lockscreen : true, - mediaSession : null, - number : 0, - priority : 0, - progressBar : false, - silent : false, - smallIcon : 'res://icon', - sound : true, - sticky : false, - summary : null, - text : '', - timeoutAfter : false, - title : '', - trigger : { type : 'calendar' }, - vibrate : false, - wakeup : true -}; -// Event listener -exports._listener = {}; +/************* + * INTERFACE * + *************/ /** - * Check permission to show notifications. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Returns the default settings. * - * @return [ Void ] + * @return {Object} */ -exports.hasPermission = function (callback, scope) { - this._exec('check', null, callback, scope); +exports.getDefaults = function () { + return this.core.getDefaults(); }; /** - * Request permission to show notifications. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Overwrite default settings. * - * @return [ Void ] + * @param {Object} defaults */ -exports.requestPermission = function (callback, scope) { - this._exec('request', null, callback, scope); +exports.setDefaults = function (defaults) { + this.core.setDefaults(defaults); }; /** - * Schedule notifications. + * Schedule a new local notification. * - * @param [ Array ] notifications The notifications to schedule. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * @param [ Object ] args Optional flags how to schedule. - * - * @return [ Void ] + * @param {Object} notifications + * The notification properties + * @param {Function} callback + * A function to be called after the notification has been canceled + * @param {Object?} scope + * The scope for the callback function + * @param {Object?} args + * skipPermission:true schedules the notifications immediatly without + * registering or checking for permission */ -exports.schedule = function (msgs, callback, scope, args) { - var fn = function (granted) { - var toasts = this._toArray(msgs); - - if (!granted && callback) { - callback.call(scope || this, false); - return; - } - - for (var i = 0, len = toasts.length; i < len; i++) { - var toast = toasts[i]; - this._mergeWithDefaults(toast); - this._convertProperties(toast); - } - - this._exec('schedule', toasts, callback, scope); - }; - - if (args && args.skipPermission) { - fn.call(this, true); - } else { - this.requestPermission(fn, this); - } +exports.schedule = function (notifications, callback, scope, args) { + this.core.schedule(notifications, callback, scope, args); }; /** - * Schedule notifications. - * - * @param [ Array ] notifications The notifications to schedule. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * @param [ Object ] args Optional flags how to schedule. + * Update existing notifications specified by IDs in options. * - * @return [ Void ] + * @param {Object} notifications + * The notification properties to update + * @param {Function} callback + * A function to be called after the notification has been updated + * @param {Object?} scope + * The scope for the callback function + * @param {Object?} args + * skipPermission:true schedules the notifications immediatly without + * registering or checking for permission */ -exports.update = function (msgs, callback, scope, args) { - var fn = function(granted) { - var toasts = this._toArray(msgs); - - if (!granted && callback) { - callback.call(scope || this, false); - return; - } - - for (var i = 0, len = toasts.length; i < len; i++) { - this._convertProperties(toasts[i]); - } - - this._exec('update', toasts, callback, scope); - }; - - if (args && args.skipPermission) { - fn.call(this, true); - } else { - this.requestPermission(fn, this); - } +exports.update = function (notifications, callback, scope, args) { + this.core.update(notifications, callback, scope, args); }; /** - * Clear the specified notifications by id. - * - * @param [ Array ] ids The IDs of the notifications. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Clear the specified notification. * - * @return [ Void ] + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A function to be called after the notification has been cleared + * @param {Object?} scope + * The scope for the callback function */ exports.clear = function (ids, callback, scope) { - ids = this._toArray(ids); - ids = this._convertIds(ids); - - this._exec('clear', ids, callback, scope); + this.core.clear(ids, callback, scope); }; /** - * Clear all triggered notifications. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Clear all previously sheduled notifications. * - * @return [ Void ] + * @param {Function} callback + * A function to be called after all notifications have been cleared + * @param {Object?} scope + * The scope for the callback function */ exports.clearAll = function (callback, scope) { - this._exec('clearAll', null, callback, scope); + this.core.clearAll(callback, scope); }; /** - * Clear the specified notifications by id. - * - * @param [ Array ] ids The IDs of the notifications. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Cancel the specified notifications. * - * @return [ Void ] + * @param {String[]} ids + * The IDs of the notifications + * @param {Function} callback + * A function to be called after the notifications has been canceled + * @param {Object?} scope + * The scope for the callback function */ exports.cancel = function (ids, callback, scope) { - ids = this._toArray(ids); - ids = this._convertIds(ids); - - this._exec('cancel', ids, callback, scope); + this.core.cancel(ids, callback, scope); }; /** - * Cancel all scheduled notifications. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Remove all previously registered notifications. * - * @return [ Void ] + * @param {Function} callback + * A function to be called after all notifications have been canceled + * @param {Object?} scope + * The scope for the callback function */ exports.cancelAll = function (callback, scope) { - this._exec('cancelAll', null, callback, scope); + this.core.cancelAll(callback, scope); }; /** - * Check if a notification is present. + * Check if a notification with an ID is present. * - * @param [ Int ] id The ID of the notification. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.isPresent = function (id, callback, scope) { - var fn = this._createCallbackFn(callback, scope); - - this.getType(id, function (type) { - fn(type != 'unknown'); - }); + this.core.isPresent(id, callback, scope); }; /** - * Check if a notification is scheduled. + * Check if a notification with an ID is scheduled. * - * @param [ Int ] id The ID of the notification. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.isScheduled = function (id, callback, scope) { - this.hasType(id, 'scheduled', callback, scope); + this.core.isScheduled(id, callback, scope); }; /** - * Check if a notification was triggered. - * - * @param [ Int ] id The ID of the notification. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * Check if a notification with an ID was triggered. * - * @return [ Void ] + * @param {String} id + * The ID of the notification + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.isTriggered = function (id, callback, scope) { - this.hasType(id, 'triggered', callback, scope); -}; - -/** - * Check if a notification has a given type. - * - * @param [ Int ] id The ID of the notification. - * @param [ String ] type The type of the notification. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] - */ -exports.hasType = function (id, type, callback, scope) { - var fn = this._createCallbackFn(callback, scope); - - this.getType(id, function (type2) { - fn(type == type2); - }); + this.core.isTriggered(id, callback, scope); }; /** - * Get the type (triggered, scheduled) for the notification. + * List all local notification IDs. * - * @param [ Int ] id The ID of the notification. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ -exports.getType = function (id, callback, scope) { - this._exec('type', id, callback, scope); +exports.getAllIds = function (callback, scope) { + this.core.getAllIds(callback, scope); }; /** - * List of all notification ids. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * Alias for `getAllIds`. */ -exports.getIds = function (callback, scope) { - this._exec('ids', 0, callback, scope); +exports.getIds = function () { + this.getAllIds.apply(this, arguments); }; /** - * List of all scheduled notification IDs. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. + * List all scheduled notification IDs. * - * @return [ Void ] + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.getScheduledIds = function (callback, scope) { - this._exec('ids', 1, callback, scope); + this.core.getScheduledIds(callback, scope); }; /** - * List of all triggered notification IDs. + * List all triggered notification IDs. * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.getTriggeredIds = function (callback, scope) { - this._exec('ids', 2, callback, scope); + this.core.getTriggeredIds(callback, scope); }; /** - * List of local notifications specified by id. + * Property list for given local notifications. * If called without IDs, all notification will be returned. * - * @param [ Array ] ids The IDs of the notifications. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * @param {Number[]?} ids + * Set of notification IDs + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.get = function () { - var args = Array.apply(null, arguments); - - if (typeof args[0] == 'function') { - args.unshift([]); - } - - var ids = args[0], - callback = args[1], - scope = args[2]; - - if (!Array.isArray(ids)) { - this._exec('notification', Number(ids), callback, scope); - return; - } - - ids = this._convertIds(ids); - - this._exec('notifications', [3, ids], callback, scope); + this.core.get.apply(this.core, arguments); }; /** - * List for all notifications. + * Property list for all local notifications. * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ exports.getAll = function (callback, scope) { - this._exec('notifications', 0, callback, scope); -}; - -/** - * List of all scheduled notifications. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - */ -exports.getScheduled = function (callback, scope) { - this._exec('notifications', 1, callback, scope); -}; - -/** - * List of all triggered notifications. - * - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - */ -exports.getTriggered = function (callback, scope) { - this._exec('notifications', 2, callback, scope); -}; - -/** - * Add an group of actions by id. - * - * @param [ String ] id The Id of the group. - * @param [ Array] actions The action config settings. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] - */ -exports.addActions = function (id, actions, callback, scope) { - this._exec('actions', [0, id, actions], callback, scope); -}; - -/** - * Remove an group of actions by id. - * - * @param [ String ] id The Id of the group. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] - */ -exports.removeActions = function (id, callback, scope) { - this._exec('actions', [1, id], callback, scope); -}; - -/** - * Check if a group of actions is defined. - * - * @param [ String ] id The Id of the group. - * @param [ Function ] callback The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] - */ -exports.hasActions = function (id, callback, scope) { - this._exec('actions', [2, id], callback, scope); -}; - -/** - * The (platform specific) default settings. - * - * @return [ Object ] - */ -exports.getDefaults = function () { - var map = Object.assign({}, this._defaults); - - for (var key in map) { - if (Array.isArray(map[key])) { - map[key] = Array.from(map[key]); - } else - if (Object.prototype.isPrototypeOf(map[key])) { - map[key] = Object.assign({}, map[key]); - } - } - - return map; -}; - -/** - * Overwrite default settings. - * - * @param [ Object ] newDefaults New default values. - * - * @return [ Void ] - */ -exports.setDefaults = function (newDefaults) { - Object.assign(this._defaults, newDefaults); -}; - -/** - * Register callback for given event. - * - * @param [ String ] event The name of the event. - * @param [ Function ] callback The function to be exec as callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Void ] - */ -exports.on = function (event, callback, scope) { - var type = typeof callback; - - if (type !== 'function' && type !== 'string') - return; - - if (!this._listener[event]) { - this._listener[event] = []; - } - - var item = [callback, scope || window]; - - this._listener[event].push(item); + this.core.getAll(callback, scope); }; /** - * Unregister callback for given event. - * - * @param [ String ] event The name of the event. - * @param [ Function ] callback The function to be exec as callback. - * - * @return [ Void ] - */ -exports.un = function (event, callback) { - var listener = this._listener[event]; - - if (!listener) - return; - - for (var i = 0; i < listener.length; i++) { - var fn = listener[i][0]; - - if (fn == callback) { - listener.splice(i, 1); - break; - } - } -}; - -/** - * Fire the event with given arguments. - * - * @param [ String ] event The event's name. - * @param [ *Array] args The callback's arguments. - * - * @return [ Void] - */ -exports.fireEvent = function (event) { - var args = Array.apply(null, arguments).slice(1), - listener = this._listener[event]; - - if (!listener) - return; - - if (args[0] && typeof args[0].data === 'string') { - args[0].data = JSON.parse(args[0].data); - } - - for (var i = 0; i < listener.length; i++) { - var fn = listener[i][0], - scope = listener[i][1]; - - if (typeof fn !== 'function') { - fn = scope[fn]; - } - - fn.apply(scope, args); - } -}; - -/** - * Fire queued events once the device is ready and all listeners are registered. + * Property list for given scheduled notifications. + * If called without IDs, all notification will be returned. * - * @return [ Void ] + * @param {Number[]?} ids + * Set of notification IDs + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ -exports.fireQueuedEvents = function() { - exports._exec('ready'); +exports.getScheduled = function () { + this.core.getScheduled.apply(this.core, arguments); }; /** - * Merge custom properties with the default values. - * - * @param [ Object ] options Set of custom values. + * Property list for all scheduled notifications. * - * @retrun [ Object ] + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ -exports._mergeWithDefaults = function (options) { - var values = this.getDefaults(); - - if (values.hasOwnProperty('sticky')) { - options.sticky = this._getValueFor(options, 'sticky', 'ongoing'); - } - - if (options.sticky && options.autoClear !== true) { - options.autoClear = false; - } - - Object.assign(values, options); - - for (var key in values) { - if (values[key] !== null) { - options[key] = values[key]; - } else { - delete options[key]; - } - - if (!this._defaults.hasOwnProperty(key)) { - console.warn('Unknown property: ' + key); - } - } - - options.meta = { - plugin: 'cordova-plugin-local-notification', - version: '0.9-beta.3' - }; - - return options; +exports.getAllScheduled = function (callback, scope) { + this.core.getAllScheduled(callback, scope); }; /** - * Convert the passed values to their required type. - * - * @param [ Object ] options Properties to convert for. + * Property list for given triggered notifications. + * If called without IDs, all notification will be returned. * - * @return [ Object ] The converted property list + * @param {Number[]?} ids + * Set of notification IDs + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ -exports._convertProperties = function (options) { - var parseToInt = function (prop, options) { - if (isNaN(options[prop])) { - console.warn(prop + ' is not a number: ' + options[prop]); - return this._defaults[prop]; - } else { - return Number(options[prop]); - } - }; - - if (options.id) { - options.id = parseToInt('id', options); - } - - if (options.title) { - options.title = options.title.toString(); - } - - if (options.badge) { - options.badge = parseToInt('badge', options); - } - - if (options.defaults) { - options.defaults = parseToInt('defaults', options); - } - - if (options.smallIcon && !options.smallIcon.match(/^res:/)) { - console.warn('Property "smallIcon" must be of kind res://...'); - } - - if (typeof options.timeoutAfter === 'boolean') { - options.timeoutAfter = options.timeoutAfter ? 3600000 : null; - } - - if (options.timeoutAfter) { - options.timeoutAfter = parseToInt('timeoutAfter', options); - } - - options.data = JSON.stringify(options.data); - - this._convertPriority(options); - this._convertTrigger(options); - this._convertActions(options); - this._convertProgressBar(options); - - return options; +exports.getTriggered = function () { + this.core.getTriggered.apply(this.core, arguments); }; /** - * Convert the passed values for the priority to their required type. + * Property list for all triggered notifications. * - * @param [ Map ] options Set of custom values. - * - * @return [ Map ] Interaction object with trigger spec. + * @param {Function} callback + * A callback function to be called with the list + * @param {Object?} scope + * The scope for the callback function */ -exports._convertPriority = function (options) { - var prio = options.priority || options.prio || 0; - - if (typeof prio === 'string') { - prio = { min: -2, low: -1, high: 1, max: 2 }[prio] || 0; - } - - if (options.foreground === true) { - prio = Math.max(prio, 1); - } - - if (options.foreground === false) { - prio = Math.min(prio, 0); - } - - options.priority = prio; - - return options; +exports.getAllTriggered = function (callback, scope) { + this.core.getAllTriggered(callback, scope); }; /** - * Convert the passed values to their required type, modifying them - * directly for Android and passing the converted list back for iOS. + * Informs if the app has the permission to show notifications. * - * @param [ Map ] options Set of custom values. - * - * @return [ Map ] Interaction object with category & actions. + * @param {Function} callback + * The function to be exec as the callback + * @param {Object?} scope + * The callback function's scope */ -exports._convertActions = function (options) { - var actions = []; - - if (!options.actions || typeof options.actions === 'string') - return options; - - for (var i = 0, len = options.actions.length; i < len; i++) { - var action = options.actions[i]; - - if (!action.id) { - console.warn('Action with title ' + action.title + ' ' + - 'has no id and will not be added.'); - continue; - } - - action.id = action.id.toString(); - - actions.push(action); - } - - options.actions = actions; - - return options; +exports.hasPermission = function (callback, scope) { + this.core.hasPermission(callback, scope); }; /** - * Convert the passed values for the trigger to their required type. + * Register permission to show notifications if not already granted. * - * @param [ Map ] options Set of custom values. - * - * @return [ Map ] Interaction object with trigger spec. + * @param {Function} callback + * The function to be exec as the callback + * @param {Object?} scope + * The callback function's scope */ -exports._convertTrigger = function (options) { - var trigger = options.trigger || {}, - date = this._getValueFor(trigger, 'at', 'firstAt', 'date'); - - var dateToNum = function (date) { - var num = typeof date == 'object' ? date.getTime() : date; - return Math.round(num); - }; - - if (!options.trigger) - return; - - if (!trigger.type) { - trigger.type = trigger.center ? 'location' : 'calendar'; - } - - var isCal = trigger.type == 'calendar'; - - if (isCal && !date) { - date = this._getValueFor(options, 'at', 'firstAt', 'date'); - } - - if (isCal && !trigger.every && options.every) { - trigger.every = options.every; - } - - if (isCal && (trigger.in || trigger.every)) { - date = null; - } - - if (isCal && date) { - trigger.at = dateToNum(date); - } - - if (isCal && trigger.firstAt) { - trigger.firstAt = dateToNum(trigger.firstAt); - } - - if (isCal && trigger.before) { - trigger.before = dateToNum(trigger.before); - } - - if (isCal && trigger.after) { - trigger.after = dateToNum(trigger.after); - } - - if (!trigger.count && device.platform == 'windows') { - trigger.count = trigger.every ? 5 : 1; - } - - if (trigger.count && device.platform == 'iOS') { - console.warn('trigger: { count: } is not supported on iOS.'); - } - - if (!isCal) { - trigger.notifyOnEntry = !!trigger.notifyOnEntry; - trigger.notifyOnExit = trigger.notifyOnExit === true; - trigger.radius = trigger.radius || 5; - trigger.single = !!trigger.single; - } - - if (!isCal || trigger.at) { - delete trigger.every; - } - - delete options.every; - delete options.at; - delete options.firstAt; - delete options.date; - - options.trigger = trigger; - - return options; +exports.registerPermission = function (callback, scope) { + this.core.registerPermission(callback, scope); }; /** - * Convert the passed values for the progressBar to their required type. - * - * @param [ Map ] options Set of custom values. - * - * @return [ Map ] Interaction object with trigger spec. + * Inform that webapp is ready, listeneres are registered + * and all queued event can be executed */ -exports._convertProgressBar = function (options) { - var isAndroid = device.platform == 'Android', - cfg = options.progressBar; - - if (cfg === undefined) - return; - - if (typeof cfg === 'boolean') { - cfg = options.progressBar = { enabled: cfg }; - } - - if (typeof cfg.enabled !== 'boolean') { - cfg.enabled = !!(cfg.value || cfg.maxValue || cfg.indeterminate !== null); - } - - cfg.value = cfg.value || 0; - - if (isAndroid) { - cfg.maxValue = cfg.maxValue || 100; - cfg.indeterminate = !!cfg.indeterminate; - } - - cfg.enabled = !!cfg.enabled; - - if (cfg.enabled && options.clock === true) { - options.clock = 'chronometer'; - } - - return options; -}; +exports.deviceReady = function() { + this.core.deviceready(); +} +/**************** + * DEPRECATIONS * + ****************/ /** - * Create a callback function to get executed within a specific scope. - * - * @param [ Function ] fn The function to be exec as the callback. - * @param [ Object ] scope The callback function's scope. - * - * @return [ Function ] + * Schedule a new local notification. */ -exports._createCallbackFn = function (fn, scope) { +exports.add = function () { + console.warn('Depreated: Please use `notification.local.schedule` instead.'); - if (typeof fn != 'function') - return; - - return function () { - fn.apply(scope || this, arguments); - }; + this.schedule.apply(this, arguments); }; /** - * Convert the IDs to numbers. - * - * @param [ Array ] ids - * - * @return [ Array ] + * Register permission to show notifications + * if not already granted. */ -exports._convertIds = function (ids) { - var convertedIds = []; +exports.promptForPermission = function () { + console.warn('Depreated: Please use `notification.local.registerPermission` instead.'); - for (var i = 0, len = ids.length; i < len; i++) { - convertedIds.push(Number(ids[i])); - } - - return convertedIds; + this.registerPermission.apply(this, arguments); }; -/** - * First found value for the given keys. - * - * @param [ Object ] options Object with key-value properties. - * @param [ *Array ] keys List of keys. - * - * @return [ Object ] - */ -exports._getValueFor = function (options) { - var keys = Array.apply(null, arguments).slice(1); - - for (var i = 0, key = keys[i], len = keys.length; i < len; key = keys[++i]) { - if (options.hasOwnProperty(key)) { - return options[key]; - } - } - return null; -}; +/********** + * EVENTS * + **********/ /** - * Convert a value to an array. - * - * @param [ Object ] obj Any kind of object. - * - * @return [ Array ] An array with the object as first item. - */ -exports._toArray = function (obj) { - return Array.isArray(obj) ? Array.from(obj) : [obj]; -}; - -/** - * Execute the native counterpart. - * - * @param [ String ] action The name of the action. - * @param [ Array ] args Array of arguments. - * @param [ Function] callback The callback function. - * @param [ Object ] scope The scope for the function. + * Register callback for given event. * - * @return [ Void ] + * @param {String} event + * The event's name + * @param {Function} callback + * The function to be exec as callback + * @param {Object?} scope + * The callback function's scope */ -exports._exec = function (action, args, callback, scope) { - var fn = this._createCallbackFn(callback, scope), - params = []; - - if (Array.isArray(args)) { - params = args; - } else if (args) { - params.push(args); - } - - exec(fn, null, 'LocalNotification', action, params); +exports.on = function (event, callback, scope) { + this.core.on(event, callback, scope); }; /** - * Set the launch details if the app was launched by clicking on a toast. + * Unregister callback for given event. * - * @return [ Void ] + * @param {String} event + * The event's name + * @param {Function} callback + * The function to be exec as callback */ -exports._setLaunchDetails = function () { - exports._exec('launch', null, function (details) { - if (details) { - exports.launchDetails = details; - } - }); +exports.un = function (event, callback) { + this.core.un(event, callback); }; - -// Polyfill for Object.assign -if (typeof Object.assign != 'function') { - Object.assign = function(target) { - 'use strict'; - if (target == null) { - throw new TypeError('Cannot convert undefined or null to object'); - } - - target = Object(target); - for (var index = 1; index < arguments.length; index++) { - var source = arguments[index]; - if (source != null) { - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - } - return target; - }; -} - -// Polyfill for Array.from -// Production steps of ECMA-262, Edition 6, 22.1.2.1 -// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from -if (!Array.from) { - Array.from = (function () { - var toStr = Object.prototype.toString; - var isCallable = function (fn) { - return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; - }; - var toInteger = function (value) { - var number = Number(value); - if (isNaN(number)) { return 0; } - if (number === 0 || !isFinite(number)) { return number; } - return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); - }; - var maxSafeInteger = Math.pow(2, 53) - 1; - var toLength = function (value) { - var len = toInteger(value); - return Math.min(Math.max(len, 0), maxSafeInteger); - }; - - // The length property of the from method is 1. - return function from(arrayLike/*, mapFn, thisArg */) { - // 1. Let C be the this value. - var C = this; - - // 2. Let items be ToObject(arrayLike). - var items = Object(arrayLike); - - // 3. ReturnIfAbrupt(items). - if (arrayLike == null) { - throw new TypeError("Array.from requires an array-like object - not null or undefined"); - } - - // 4. If mapfn is undefined, then let mapping be false. - var mapFn = arguments.length > 1 ? arguments[1] : void undefined; - var T; - if (typeof mapFn !== 'undefined') { - // 5. else - // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. - if (!isCallable(mapFn)) { - throw new TypeError('Array.from: when provided, the second argument must be a function'); - } - - // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. - if (arguments.length > 2) { - T = arguments[2]; - } - } - - // 10. Let lenValue be Get(items, "length"). - // 11. Let len be ToLength(lenValue). - var len = toLength(items.length); - - // 13. If IsConstructor(C) is true, then - // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len. - // 14. a. Else, Let A be ArrayCreate(len). - var A = isCallable(C) ? Object(new C(len)) : new Array(len); - - // 16. Let k be 0. - var k = 0; - // 17. Repeat, while k < len… (also steps a - h) - var kValue; - while (k < len) { - kValue = items[k]; - if (mapFn) { - A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); - } else { - A[k] = kValue; - } - k += 1; - } - // 18. Let putStatus be Put(A, "length", len, true). - A.length = len; - // 20. Return A. - return A; - }; - }()); -} - -// Called after 'deviceready' event -channel.deviceready.subscribe(function () { - if (!window.skipLocalNotificationReady) { - exports.fireQueuedEvents(); - } -}); - -// Called before 'deviceready' event -channel.onCordovaReady.subscribe(function () { - channel.onCordovaInfoReady.subscribe(function () { - exports._setLaunchDetails(); - }); -});