This repository was archived by the owner on Aug 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpush.ios.js
More file actions
9 lines (9 loc) · 16.8 KB
/
push.ios.js
File metadata and controls
9 lines (9 loc) · 16.8 KB
1
2
3
4
5
6
7
8
9
/**
* kinvey-nativescript-sdk - Kinvey NativeScript SDK for developing NativeScript applications.
* @version v3.12.6
* @author Kinvey, Inc.
* @link http://www.kinvey.com
* @license Apache-2.0
*/
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=580)}({0:function(e,t,n){(function(t,r){var i;i=function(){"use strict";function e(e){return"function"==typeof e}var i=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=0,s=void 0,u=void 0,c=function(e,t){d[o]=e,d[o+1]=t,2===(o+=2)&&(u?u(_):b())};var a="undefined"!=typeof window?window:void 0,h=a||{},f=h.MutationObserver||h.WebKitMutationObserver,l="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),v="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var e=setTimeout;return function(){return e(_,1)}}var d=new Array(1e3);function _(){for(var e=0;e<o;e+=2){(0,d[e])(d[e+1]),d[e]=void 0,d[e+1]=void 0}o=0}var y,m,g,w,b=void 0;function P(e,t){var n=arguments,r=this,i=new this.constructor(E);void 0===i[A]&&I(i);var o,s=r._state;return s?(o=n[s-1],c(function(){return Y(s,i,o,r._result)})):R(r,i,e,t),i}function T(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(E);return O(t,e),t}l?b=function(){return t.nextTick(_)}:f?(m=0,g=new f(_),w=document.createTextNode(""),g.observe(w,{characterData:!0}),b=function(){w.data=m=++m%2}):v?((y=new MessageChannel).port1.onmessage=_,b=function(){return y.port2.postMessage(0)}):b=void 0===a?function(){try{var e=n(93);return void 0!==(s=e.runOnLoop||e.runOnContext)?function(){s(_)}:p()}catch(e){return p()}}():p();var A=Math.random().toString(36).substring(16);function E(){}var L=void 0,k=1,x=2,j=new N;function U(e){try{return e.then}catch(e){return j.error=e,j}}function C(t,n,r){n.constructor===t.constructor&&r===P&&n.constructor.resolve===T?function(e,t){t._state===k?K(e,t._result):t._state===x?M(e,t._result):R(t,void 0,function(t){return O(e,t)},function(t){return M(e,t)})}(t,n):r===j?(M(t,j.error),j.error=null):void 0===r?K(t,n):e(r)?function(e,t,n){c(function(e){var r=!1,i=function(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}(n,t,function(n){r||(r=!0,t!==n?O(e,n):K(e,n))},function(t){r||(r=!0,M(e,t))},e._label);!r&&i&&(r=!0,M(e,i))},e)}(t,n,r):K(t,n)}function O(e,t){var n,r;e===t?M(e,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=t),null===n||"object"!==r&&"function"!==r?K(e,t):C(e,t,U(t)))}function S(e){e._onerror&&e._onerror(e._result),W(e)}function K(e,t){e._state===L&&(e._result=t,e._state=k,0!==e._subscribers.length&&c(W,e))}function M(e,t){e._state===L&&(e._state=x,e._result=t,c(S,e))}function R(e,t,n,r){var i=e._subscribers,o=i.length;e._onerror=null,i[o]=t,i[o+k]=n,i[o+x]=r,0===o&&e._state&&c(W,e)}function W(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r=void 0,i=void 0,o=e._result,s=0;s<t.length;s+=3)r=t[s],i=t[s+n],r?Y(n,r,i,o):i(o);e._subscribers.length=0}}function N(){this.error=null}var F=new N;function Y(t,n,r,i){var o=e(r),s=void 0,u=void 0,c=void 0,a=void 0;if(o){if((s=function(e,t){try{return e(t)}catch(e){return F.error=e,F}}(r,i))===F?(a=!0,u=s.error,s.error=null):c=!0,n===s)return void M(n,new TypeError("A promises callback cannot return that same promise."))}else s=i,c=!0;n._state!==L||(o&&c?O(n,s):a?M(n,u):t===k?K(n,s):t===x&&M(n,s))}var q=0;function I(e){e[A]=q++,e._state=void 0,e._result=void 0,e._subscribers=[]}function B(e,t){this._instanceConstructor=e,this.promise=new e(E),this.promise[A]||I(this.promise),i(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?K(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&K(this.promise,this._result))):M(this.promise,new Error("Array Methods must be provided an Array"))}function D(e){this[A]=q++,this._result=this._state=void 0,this._subscribers=[],E!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof D?function(e,t){try{t(function(t){O(e,t)},function(t){M(e,t)})}catch(t){M(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return B.prototype._enumerate=function(e){for(var t=0;this._state===L&&t<e.length;t++)this._eachEntry(e[t],t)},B.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,r=n.resolve;if(r===T){var i=U(e);if(i===P&&e._state!==L)this._settledAt(e._state,t,e._result);else if("function"!=typeof i)this._remaining--,this._result[t]=e;else if(n===D){var o=new n(E);C(o,e,i),this._willSettleAt(o,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(r(e),t)},B.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===L&&(this._remaining--,e===x?M(r,n):this._result[t]=n),0===this._remaining&&K(r,this._result)},B.prototype._willSettleAt=function(e,t){var n=this;R(e,void 0,function(e){return n._settledAt(k,t,e)},function(e){return n._settledAt(x,t,e)})},D.all=function(e){return new B(this,e).promise},D.race=function(e){var t=this;return i(e)?new t(function(n,r){for(var i=e.length,o=0;o<i;o++)t.resolve(e[o]).then(n,r)}):new t(function(e,t){return t(new TypeError("You must pass an array to race."))})},D.resolve=T,D.reject=function(e){var t=new this(E);return M(t,e),t},D._setScheduler=function(e){u=e},D._setAsap=function(e){c=e},D._asap=c,D.prototype={constructor:D,then:P,catch:function(e){return this.then(null,e)}},D.polyfill=function(){var e=void 0;if(void 0!==r)e=r;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=D},D.Promise=D,D},e.exports=i()}).call(t,n(92),n(23))},126:function(e,t){e.exports=require("platform")},23:function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},234:function(e,t){e.exports=require("./kinvey-nativescript-sdk")},55:function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,s,u,c,a;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(o(n=this._events[e]))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:u=Array.prototype.slice.call(arguments,1),n.apply(this,u)}else if(i(n))for(u=Array.prototype.slice.call(arguments,1),s=(a=n.slice()).length,c=0;c<s;c++)a[c].apply(this,u);return!0},n.prototype.addListener=function(e,t){var s;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(s=o(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&s>0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},n.prototype.removeListener=function(e,t){var n,o,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(u=s;u-- >0;)if(n[u]===t||n[u].listener&&n[u].listener===t){o=u;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},580:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=n(0),o=n(234),s=n(581);try{r=n(582)}catch(e){}var u=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype._registerWithPushPlugin=function(e){var t=this;void 0===e&&(e={});var n=e.ios||{};return new i.Promise(function(i,s){if(!r)return s(new o.KinveyError("NativeScript Push Plugin is not installed.","Please refer to http://devcenter.kinvey.com/nativescript/guides/push#ProjectSetUp for help with setting up your project."));var u=n.notificationCallbackIOS;n.notificationCallbackIOS=function(n){"function"==typeof u&&u(n),"function"==typeof e.notificationCallback&&(n.foreground="1"===n.foreground,e.notificationCallback(n)),t.emit("notification",n)},r.register(n,function(e){n.interactiveSettings?r.registerUserNotificationSettings(function(){i(e)},function(t){i(e)}):i(e)},s)})},t.prototype._unregisterWithPushPlugin=function(e){void 0===e&&(e={});var t=e.ios||{};return new i.Promise(function(e,n){if(!r)return n(new o.KinveyError("NativeScript Push Plugin is not installed.","Please refer to http://devcenter.kinvey.com/nativescript/guides/push#ProjectSetUp for help with setting up your project."));r.unregister(e,n,t)})},t}(s.PushCommon));t.Push=u},581:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(55),o=n(126),s=n(234),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"client",{get:function(){return s.client()},enumerable:!0,configurable:!0}),t.prototype.onNotification=function(e){return this.on("notification",e)},t.prototype.onceNotification=function(e){return this.once("notification",e)},t.prototype.register=function(e){var t=this;return void 0===e&&(e={}),this._registerWithPushPlugin(e).then(function(n){if(!n)throw new s.KinveyError("Unable to retrieve the device token to register this device for push notifications.");return t._registerWithKinvey(n,e)}).then(function(e){return t._saveTokenToCache(e)})},t.prototype.unregister=function(e){var t=this;return void 0===e&&(e={}),this._unregisterWithPushPlugin(e).then(function(){return t._getTokenFromCache()}).then(function(n){if(!n)throw new s.KinveyError("Unable to retrieve the device token to unregister this device for push notifications.");return t._unregisterWithKinvey(n,e)}).then(function(){return t._deleteTokenFromCache()})},t.prototype._registerWithPushPlugin=function(e){return void 0===e&&(e={}),r.Promise.reject(new s.KinveyError("Unable to register for push notifications."))},t.prototype._unregisterWithPushPlugin=function(e){return void 0===e&&(e={}),r.Promise.reject(new s.KinveyError("Unable to unregister for push notifications."))},t.prototype._registerWithKinvey=function(e,t){void 0===t&&(t={});var n=s.User.getActiveUser(this.client);return n?new s.KinveyRequest({method:s.RequestMethod.POST,url:this.client.apiHostname+"/push/"+this.client.appKey+"/register-device",authType:n?s.AuthType.Session:s.AuthType.Master,data:{platform:o.device.os.toLowerCase(),framework:"nativescript",deviceId:e},timeout:t.timeout,client:this.client}).execute().then(function(){return e}):r.Promise.reject(new s.KinveyError("Unable to register this device for push notifications.","You must login a user."))},t.prototype._unregisterWithKinvey=function(e,t){void 0===t&&(t={});var n=s.User.getActiveUser(this.client);return n?new s.KinveyRequest({method:s.RequestMethod.POST,url:this.client.apiHostname+"/push/"+this.client.appKey+"/unregister-device",authType:n?s.AuthType.Session:s.AuthType.Master,data:{platform:o.device.os.toLowerCase(),framework:"nativescript",deviceId:e},timeout:t.timeout,client:this.client}).execute().then(function(e){return e.data}):r.Promise.reject(new s.KinveyError("Unable to unregister this device for push notifications.","You must login a user."))},t.prototype._getTokenFromCache=function(){var e=s.User.getActiveUser(this.client);if(!e)throw new s.KinveyError("Unable to retrieve device token.","You must login a user.");return this._getOfflineRepo().then(function(t){return t.readById("__device",e._id)}).catch(function(e){if(e instanceof s.NotFoundError)return{};throw e}).then(function(e){return e?e.token:null})},t.prototype._saveTokenToCache=function(e){var t=s.User.getActiveUser(this.client);if(!t)throw new s.KinveyError("Unable to save device token.","You must login a user.");var n={_id:t._id,userId:t._id,token:e};return this._getOfflineRepo().then(function(e){return e.update("__device",n)}).then(function(){return e})},t.prototype._deleteTokenFromCache=function(){var e=s.User.getActiveUser(this.client);if(!e)throw new s.KinveyError("Unable to delete device token.","You must login a user.");return this._getOfflineRepo().then(function(t){return t.deleteById("__device",e._id)}).then(function(){return null})},t.prototype._getOfflineRepo=function(){return this._offlineRepoPromise||(this._offlineRepoPromise=s.DataAccess.repositoryProvider.getOfflineRepository()),this._offlineRepoPromise},t}(i.EventEmitter);t.PushCommon=u},582:function(e,t){e.exports=require("nativescript-push-notifications")},92:function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,a=[],h=!1,f=-1;function l(){h&&c&&(h=!1,c.length?a=c.concat(a):f=-1,a.length&&v())}function v(){if(!h){var e=u(l);h=!0;for(var t=a.length;t;){for(c=a,a=[];++f<t;)c&&c[f].run();f=-1,t=a.length}c=null,h=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function d(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];a.push(new p(e,t)),1!==a.length||h||u(v)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=d,i.addListener=d,i.once=d,i.off=d,i.removeListener=d,i.removeAllListeners=d,i.emit=d,i.prependListener=d,i.prependOnceListener=d,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},93:function(e,t){}});
//# sourceMappingURL=push.ios.js.map