summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-30 18:21:01 -0500
committerJules Laplace <jules@okfoc.us>2015-11-30 18:21:01 -0500
commitded2f8928dd509acc8d4ae1e4131b622c7bb4d9c (patch)
treea576defc78fac3b9c2c0d8a7beb18e78d6466255 /StoneIsland/platforms/ios/www
parent60bd9bf61e4d1f3fb3925807ca754f89743cfade (diff)
phonegap-plugin-push
Diffstat (limited to 'StoneIsland/platforms/ios/www')
-rw-r--r--StoneIsland/platforms/ios/www/cordova_plugins.js10
-rw-r--r--StoneIsland/platforms/ios/www/plugins/phonegap-plugin-push/www/push.js231
2 files changed, 240 insertions, 1 deletions
diff --git a/StoneIsland/platforms/ios/www/cordova_plugins.js b/StoneIsland/platforms/ios/www/cordova_plugins.js
index cb7aedde..fbdc76c9 100644
--- a/StoneIsland/platforms/ios/www/cordova_plugins.js
+++ b/StoneIsland/platforms/ios/www/cordova_plugins.js
@@ -84,6 +84,13 @@ module.exports = [
"clobbers": [
"navigator.splashscreen"
]
+ },
+ {
+ "file": "plugins/phonegap-plugin-push/www/push.js",
+ "id": "phonegap-plugin-push.PushNotification",
+ "clobbers": [
+ "PushNotification"
+ ]
}
];
module.exports.metadata =
@@ -96,7 +103,8 @@ module.exports.metadata =
"cordova-plugin-dialogs": "1.1.1",
"cordova-plugin-geolocation": "1.0.1",
"cordova-plugin-network-information": "1.0.1",
- "cordova-plugin-splashscreen": "2.1.0"
+ "cordova-plugin-splashscreen": "2.1.0",
+ "phonegap-plugin-push": "1.4.4"
}
// BOTTOM OF METADATA
}); \ No newline at end of file
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
new file mode 100644
index 00000000..7aa30fd7
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-push/www/push.js
@@ -0,0 +1,231 @@
+cordova.define("phonegap-plugin-push.PushNotification", function(require, exports, module) { /* global cordova:false */
+
+/*!
+ * Module dependencies.
+ */
+
+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(options) {
+ this._handlers = {
+ 'registration': [],
+ 'notification': [],
+ 'error': []
+ };
+
+ // require options parameter
+ if (typeof options === 'undefined') {
+ 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 && typeof result.callback !== 'undefined') {
+ var executeFunctionByName = function(functionName, context /*, args */) {
+ var args = Array.prototype.slice.call(arguments, 2);
+ var namespaces = functionName.split(".");
+ var func = namespaces.pop();
+ for (var i = 0; i < namespaces.length; i++) {
+ context = context[namespaces[i]];
+ }
+ return context[func].apply(context, args);
+ }
+
+ executeFunctionByName(result.callback, window, result);
+ } else if (result) {
+ that.emit('notification', result);
+ }
+ };
+
+ // triggered on error
+ 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]);
+ }, 10);
+};
+
+/**
+ * Unregister from push notifications
+ */
+
+PushNotification.prototype.unregister = function(successCallback, errorCallback, options) {
+ if (errorCallback == null) { 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");
+ return
+ }
+
+ exec(successCallback, errorCallback, "PushNotification", "unregister", [options]);
+};
+
+/**
+ * Call this to set the application icon badge
+ */
+
+PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) {
+ if (errorCallback == null) { errorCallback = 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");
+ return
+ }
+
+ exec(successCallback, errorCallback, "PushNotification", "setApplicationIconBadgeNumber", [{badge: badge}]);
+};
+
+/**
+ * Get the application icon badge
+ */
+
+PushNotification.prototype.getApplicationIconBadgeNumber = function(successCallback, errorCallback) {
+ if (errorCallback == null) { errorCallback = 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");
+ return
+ }
+
+ exec(successCallback, errorCallback, "PushNotification", "getApplicationIconBadgeNumber", []);
+};
+
+/**
+ * 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].push(callback);
+ }
+};
+
+/**
+ * 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);
+ if (handleIndex >= 0)
+ 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.
+ */
+
+PushNotification.prototype.emit = function() {
+ var args = Array.prototype.slice.call(arguments);
+ var eventName = args.shift();
+
+ if (!this._handlers.hasOwnProperty(eventName)) {
+ return false;
+ }
+
+ for (var i = 0, length = this._handlers[eventName].length; i < length; i++) {
+ this._handlers[eventName][i].apply(undefined,args);
+ }
+
+ return true;
+};
+
+PushNotification.prototype.finish = function(successCallback, errorCallback) {
+ if (successCallback == null) { successCallback = function() {}}
+ if (errorCallback == null) { errorCallback = function() {}}
+
+ if (typeof successCallback != "function") {
+ console.log("finish failure: success callback parameter must be a function");
+ return
+ }
+
+ if (typeof errorCallback != "function") {
+ console.log("finish failure: failure parameter not a function");
+ return
+ }
+
+ exec(successCallback, errorCallback, 'PushNotification', 'finish', []);
+}
+
+/*!
+ * 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);
+ },
+
+ /**
+ * PushNotification Object.
+ *
+ * Expose the PushNotification object for direct use
+ * and testing. Typically, you should use the
+ * .init helper method.
+ */
+
+ PushNotification: PushNotification
+};
+});