react-onesignal
Advanced tools
Comparing version 2.0.1 to 2.0.2
1813
dist/index.es.js
@@ -1,1124 +0,863 @@ | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var ONESIGNAL_SDK_ID = 'onesignal-sdk'; | ||
var MODULE_ID = 'onesignal-module'; | ||
var ONE_SIGNAL_SCRIPT_SRC = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'; | ||
var ONESIGNAL_NOT_SETUP_ERROR = 'OneSignal is not setup correctly.'; | ||
var reactOneSignalFunctionQueue = []; | ||
var MAX_TIMEOUT = 30; | ||
var getModuleScriptBody = function getModuleScriptBody() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var mappedOptions = JSON.stringify(options, null, 2); | ||
return "\n var OneSignal = window.OneSignal || [];\n OneSignal.push(function() {\n OneSignal.init(".concat(mappedOptions, ");\n });\n "); | ||
const ONESIGNAL_SDK_ID = 'onesignal-sdk'; | ||
const ONE_SIGNAL_SCRIPT_SRC = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'; | ||
const ONESIGNAL_NOT_SETUP_ERROR = 'OneSignal is not setup correctly.'; | ||
const reactOneSignalFunctionQueue = []; | ||
const MAX_TIMEOUT = 30; | ||
let isOneSignalInitialized = false; | ||
const injectScript = () => { | ||
const script = document.createElement('script'); | ||
script.id = ONESIGNAL_SDK_ID; | ||
script.src = ONE_SIGNAL_SCRIPT_SRC; | ||
script.async = true; | ||
document.head.appendChild(script); | ||
}; | ||
var injectScript = function injectScript(id, buildScript) { | ||
var hasScript = !!document.getElementById(id); | ||
if (hasScript) { | ||
return; | ||
} | ||
var script = document.createElement('script'); | ||
script.id = id; | ||
script = buildScript(script); | ||
document.body.appendChild(script); | ||
const processQueuedOneSignalFunctions = () => { | ||
reactOneSignalFunctionQueue.forEach(element => { | ||
const { name, args, promiseResolver } = element; | ||
if (!!promiseResolver) { | ||
OneSignalReact[name](...args).then(result => { | ||
promiseResolver(result); | ||
}); | ||
} | ||
else { | ||
OneSignalReact[name](...args); | ||
} | ||
}); | ||
}; | ||
var injectSDKScript = function injectSDKScript() { | ||
injectScript(ONESIGNAL_SDK_ID, function (script) { | ||
script.src = ONE_SIGNAL_SCRIPT_SRC; | ||
return script; | ||
}); | ||
const doesOneSignalExist = () => { | ||
if (window["OneSignal"]) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
var injectModuleScript = function injectModuleScript() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
injectScript(MODULE_ID, function (script) { | ||
script.innerHTML = getModuleScriptBody(options); | ||
script.async = true; | ||
return script; | ||
}); | ||
const setupOneSignalIfMissing = () => { | ||
if (!doesOneSignalExist()) { | ||
window["OneSignal"] = window["OneSignal"] || []; | ||
} | ||
}; | ||
var processQueuedOneSignalFunctions = function processQueuedOneSignalFunctions() { | ||
reactOneSignalFunctionQueue.forEach(function (element) { | ||
var name = element.name, | ||
args = element.args, | ||
promiseResolver = element.promiseResolver; | ||
if (!!promiseResolver) { | ||
OneSignalReact[name].apply(OneSignalReact, _toConsumableArray(args)).then(function (result) { | ||
promiseResolver(result); | ||
}); | ||
} else { | ||
OneSignalReact[name].apply(OneSignalReact, _toConsumableArray(args)); | ||
const init = (options) => new Promise(resolve => { | ||
if (isOneSignalInitialized) { | ||
return; | ||
} | ||
}); | ||
}; | ||
var init = function init(options) { | ||
return new Promise(function (resolve) { | ||
if (!options || !options.appId) { | ||
throw new Error('You need to provide your OneSignal appId.'); | ||
throw new Error('You need to provide your OneSignal appId.'); | ||
} | ||
if (!document) { | ||
return; | ||
return; | ||
} | ||
injectSDKScript(); | ||
injectModuleScript(options); | ||
var timeout = setTimeout(function () { | ||
console.error(ONESIGNAL_NOT_SETUP_ERROR); | ||
injectScript(); | ||
setupOneSignalIfMissing(); | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].init(options); | ||
}); | ||
const timeout = setTimeout(() => { | ||
console.error(ONESIGNAL_NOT_SETUP_ERROR); | ||
}, MAX_TIMEOUT * 1000); | ||
OneSignal.push(function () { | ||
clearTimeout(timeout); | ||
processQueuedOneSignalFunctions(); | ||
resolve(); | ||
window["OneSignal"].push(() => { | ||
clearTimeout(timeout); | ||
processQueuedOneSignalFunctions(); | ||
resolve(); | ||
}); | ||
}); | ||
}; | ||
isOneSignalInitialized = true; | ||
}); | ||
function on(event, listener) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "on", | ||
args: arguments | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "on", | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].on(event, listener); | ||
}); | ||
return; | ||
} | ||
OneSignal.push(function () { | ||
OneSignal.on(event, listener); | ||
}); | ||
} | ||
function off(event, listener) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "off", | ||
args: arguments | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "off", | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].off(event, listener); | ||
}); | ||
return; | ||
} | ||
OneSignal.push(function () { | ||
OneSignal.off(event, listener); | ||
}); | ||
} | ||
function once(event, listener) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "once", | ||
args: arguments | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "once", | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].once(event, listener); | ||
}); | ||
return; | ||
} | ||
OneSignal.push(function () { | ||
OneSignal.once(event, listener); | ||
}); | ||
} | ||
function isPushNotificationsEnabled(callback) { | ||
var _arguments = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "isPushNotificationsEnabled", | ||
args: _arguments, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.isPushNotificationsEnabled(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "isPushNotificationsEnabled", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].isPushNotificationsEnabled(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPrompt(options) { | ||
var _arguments2 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPrompt", | ||
args: _arguments2, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showHttpPrompt(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPrompt", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showHttpPrompt(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function registerForPushNotifications(options) { | ||
var _arguments3 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "registerForPushNotifications", | ||
args: _arguments3, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.registerForPushNotifications(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "registerForPushNotifications", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].registerForPushNotifications(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultNotificationUrl(url) { | ||
var _arguments4 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultNotificationUrl", | ||
args: _arguments4, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setDefaultNotificationUrl(url).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultNotificationUrl", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setDefaultNotificationUrl(url) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultTitle(title) { | ||
var _arguments5 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultTitle", | ||
args: _arguments5, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setDefaultTitle(title).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultTitle", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setDefaultTitle(title) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getTags(callback) { | ||
var _arguments6 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getTags", | ||
args: _arguments6, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getTags(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getTags", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getTags(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTag(key, value, callback) { | ||
var _arguments7 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTag", | ||
args: _arguments7, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.sendTag(key, value, callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTag", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].sendTag(key, value, callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTags(tags, callback) { | ||
var _arguments8 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTags", | ||
args: _arguments8, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.sendTags(tags, callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTags", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].sendTags(tags, callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTag(tag) { | ||
var _arguments9 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTag", | ||
args: _arguments9, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.deleteTag(tag).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTag", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].deleteTag(tag) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTags(tags, callback) { | ||
var _arguments10 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTags", | ||
args: _arguments10, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.deleteTags(tags, callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTags", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].deleteTags(tags, callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function addListenerForNotificationOpened(callback) { | ||
var _arguments11 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "addListenerForNotificationOpened", | ||
args: _arguments11, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.addListenerForNotificationOpened(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "addListenerForNotificationOpened", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].addListenerForNotificationOpened(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setSubscription(newSubscription) { | ||
var _arguments12 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSubscription", | ||
args: _arguments12, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setSubscription(newSubscription).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSubscription", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setSubscription(newSubscription) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPermissionRequest(options) { | ||
var _arguments13 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPermissionRequest", | ||
args: _arguments13, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showHttpPermissionRequest(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPermissionRequest", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showHttpPermissionRequest(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showNativePrompt() { | ||
var _arguments14 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showNativePrompt", | ||
args: _arguments14, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showNativePrompt().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showNativePrompt", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showNativePrompt() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSlidedownPrompt(options) { | ||
var _arguments15 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSlidedownPrompt", | ||
args: _arguments15, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showSlidedownPrompt(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSlidedownPrompt", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showSlidedownPrompt(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showCategorySlidedown(options) { | ||
var _arguments16 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showCategorySlidedown", | ||
args: _arguments16, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showCategorySlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showCategorySlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showCategorySlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSmsSlidedown(options) { | ||
var _arguments17 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsSlidedown", | ||
args: _arguments17, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showSmsSlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsSlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showSmsSlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showEmailSlidedown(options) { | ||
var _arguments18 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showEmailSlidedown", | ||
args: _arguments18, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showEmailSlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showEmailSlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showEmailSlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSmsAndEmailSlidedown(options) { | ||
var _arguments19 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsAndEmailSlidedown", | ||
args: _arguments19, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showSmsAndEmailSlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsAndEmailSlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showSmsAndEmailSlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getNotificationPermission(onComplete) { | ||
var _arguments20 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getNotificationPermission", | ||
args: _arguments20, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getNotificationPermission(onComplete).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getNotificationPermission", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getNotificationPermission(onComplete) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getUserId(callback) { | ||
var _arguments21 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getUserId", | ||
args: _arguments21, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getUserId(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getUserId(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getSubscription(callback) { | ||
var _arguments22 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSubscription", | ||
args: _arguments22, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getSubscription(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSubscription", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getSubscription(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setEmail(email, options) { | ||
var _arguments23 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setEmail", | ||
args: _arguments23, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setEmail(email, options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setEmail", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setEmail(email, options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setSMSNumber(smsNumber, options) { | ||
var _arguments24 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSMSNumber", | ||
args: _arguments24, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setSMSNumber(smsNumber, options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSMSNumber", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setSMSNumber(smsNumber, options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function logoutEmail() { | ||
var _arguments25 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutEmail", | ||
args: _arguments25, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.logoutEmail().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutEmail", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].logoutEmail() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function logoutSMS() { | ||
var _arguments26 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutSMS", | ||
args: _arguments26, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.logoutSMS().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutSMS", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].logoutSMS() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setExternalUserId(externalUserId, authHash) { | ||
var _arguments27 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setExternalUserId", | ||
args: _arguments27, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setExternalUserId(externalUserId, authHash).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setExternalUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setExternalUserId(externalUserId, authHash) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function removeExternalUserId() { | ||
var _arguments28 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "removeExternalUserId", | ||
args: _arguments28, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.removeExternalUserId().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "removeExternalUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].removeExternalUserId() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getExternalUserId() { | ||
var _arguments29 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getExternalUserId", | ||
args: _arguments29, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getExternalUserId().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getExternalUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getExternalUserId() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function provideUserConsent(consent) { | ||
var _arguments30 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "provideUserConsent", | ||
args: _arguments30, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.provideUserConsent(consent).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "provideUserConsent", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].provideUserConsent(consent) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getEmailId(callback) { | ||
var _arguments31 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getEmailId", | ||
args: _arguments31, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getEmailId(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getEmailId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getEmailId(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getSMSId(callback) { | ||
var _arguments32 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSMSId", | ||
args: _arguments32, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getSMSId(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSMSId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getSMSId(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendOutcome(outcomeName, outcomeWeight) { | ||
var _arguments33 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendOutcome", | ||
args: _arguments33, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.sendOutcome(outcomeName, outcomeWeight).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendOutcome", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].sendOutcome(outcomeName, outcomeWeight) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
var OneSignalReact = { | ||
init: init, | ||
on: on, | ||
off: off, | ||
once: once, | ||
isPushNotificationsEnabled: isPushNotificationsEnabled, | ||
showHttpPrompt: showHttpPrompt, | ||
registerForPushNotifications: registerForPushNotifications, | ||
setDefaultNotificationUrl: setDefaultNotificationUrl, | ||
setDefaultTitle: setDefaultTitle, | ||
getTags: getTags, | ||
sendTag: sendTag, | ||
sendTags: sendTags, | ||
deleteTag: deleteTag, | ||
deleteTags: deleteTags, | ||
addListenerForNotificationOpened: addListenerForNotificationOpened, | ||
setSubscription: setSubscription, | ||
showHttpPermissionRequest: showHttpPermissionRequest, | ||
showNativePrompt: showNativePrompt, | ||
showSlidedownPrompt: showSlidedownPrompt, | ||
showCategorySlidedown: showCategorySlidedown, | ||
showSmsSlidedown: showSmsSlidedown, | ||
showEmailSlidedown: showEmailSlidedown, | ||
showSmsAndEmailSlidedown: showSmsAndEmailSlidedown, | ||
getNotificationPermission: getNotificationPermission, | ||
getUserId: getUserId, | ||
getSubscription: getSubscription, | ||
setEmail: setEmail, | ||
setSMSNumber: setSMSNumber, | ||
logoutEmail: logoutEmail, | ||
logoutSMS: logoutSMS, | ||
setExternalUserId: setExternalUserId, | ||
removeExternalUserId: removeExternalUserId, | ||
getExternalUserId: getExternalUserId, | ||
provideUserConsent: provideUserConsent, | ||
getEmailId: getEmailId, | ||
getSMSId: getSMSId, | ||
sendOutcome: sendOutcome | ||
const OneSignalReact = { | ||
init, | ||
on, | ||
off, | ||
once, | ||
isPushNotificationsEnabled, | ||
showHttpPrompt, | ||
registerForPushNotifications, | ||
setDefaultNotificationUrl, | ||
setDefaultTitle, | ||
getTags, | ||
sendTag, | ||
sendTags, | ||
deleteTag, | ||
deleteTags, | ||
addListenerForNotificationOpened, | ||
setSubscription, | ||
showHttpPermissionRequest, | ||
showNativePrompt, | ||
showSlidedownPrompt, | ||
showCategorySlidedown, | ||
showSmsSlidedown, | ||
showEmailSlidedown, | ||
showSmsAndEmailSlidedown, | ||
getNotificationPermission, | ||
getUserId, | ||
getSubscription, | ||
setEmail, | ||
setSMSNumber, | ||
logoutEmail, | ||
logoutSMS, | ||
setExternalUserId, | ||
removeExternalUserId, | ||
getExternalUserId, | ||
provideUserConsent, | ||
getEmailId, | ||
getSMSId, | ||
sendOutcome, | ||
}; | ||
@@ -1125,0 +864,0 @@ |
1813
dist/index.js
'use strict'; | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var ONESIGNAL_SDK_ID = 'onesignal-sdk'; | ||
var MODULE_ID = 'onesignal-module'; | ||
var ONE_SIGNAL_SCRIPT_SRC = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'; | ||
var ONESIGNAL_NOT_SETUP_ERROR = 'OneSignal is not setup correctly.'; | ||
var reactOneSignalFunctionQueue = []; | ||
var MAX_TIMEOUT = 30; | ||
var getModuleScriptBody = function getModuleScriptBody() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var mappedOptions = JSON.stringify(options, null, 2); | ||
return "\n var OneSignal = window.OneSignal || [];\n OneSignal.push(function() {\n OneSignal.init(".concat(mappedOptions, ");\n });\n "); | ||
const ONESIGNAL_SDK_ID = 'onesignal-sdk'; | ||
const ONE_SIGNAL_SCRIPT_SRC = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'; | ||
const ONESIGNAL_NOT_SETUP_ERROR = 'OneSignal is not setup correctly.'; | ||
const reactOneSignalFunctionQueue = []; | ||
const MAX_TIMEOUT = 30; | ||
let isOneSignalInitialized = false; | ||
const injectScript = () => { | ||
const script = document.createElement('script'); | ||
script.id = ONESIGNAL_SDK_ID; | ||
script.src = ONE_SIGNAL_SCRIPT_SRC; | ||
script.async = true; | ||
document.head.appendChild(script); | ||
}; | ||
var injectScript = function injectScript(id, buildScript) { | ||
var hasScript = !!document.getElementById(id); | ||
if (hasScript) { | ||
return; | ||
} | ||
var script = document.createElement('script'); | ||
script.id = id; | ||
script = buildScript(script); | ||
document.body.appendChild(script); | ||
const processQueuedOneSignalFunctions = () => { | ||
reactOneSignalFunctionQueue.forEach(element => { | ||
const { name, args, promiseResolver } = element; | ||
if (!!promiseResolver) { | ||
OneSignalReact[name](...args).then(result => { | ||
promiseResolver(result); | ||
}); | ||
} | ||
else { | ||
OneSignalReact[name](...args); | ||
} | ||
}); | ||
}; | ||
var injectSDKScript = function injectSDKScript() { | ||
injectScript(ONESIGNAL_SDK_ID, function (script) { | ||
script.src = ONE_SIGNAL_SCRIPT_SRC; | ||
return script; | ||
}); | ||
const doesOneSignalExist = () => { | ||
if (window["OneSignal"]) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
var injectModuleScript = function injectModuleScript() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
injectScript(MODULE_ID, function (script) { | ||
script.innerHTML = getModuleScriptBody(options); | ||
script.async = true; | ||
return script; | ||
}); | ||
const setupOneSignalIfMissing = () => { | ||
if (!doesOneSignalExist()) { | ||
window["OneSignal"] = window["OneSignal"] || []; | ||
} | ||
}; | ||
var processQueuedOneSignalFunctions = function processQueuedOneSignalFunctions() { | ||
reactOneSignalFunctionQueue.forEach(function (element) { | ||
var name = element.name, | ||
args = element.args, | ||
promiseResolver = element.promiseResolver; | ||
if (!!promiseResolver) { | ||
OneSignalReact[name].apply(OneSignalReact, _toConsumableArray(args)).then(function (result) { | ||
promiseResolver(result); | ||
}); | ||
} else { | ||
OneSignalReact[name].apply(OneSignalReact, _toConsumableArray(args)); | ||
const init = (options) => new Promise(resolve => { | ||
if (isOneSignalInitialized) { | ||
return; | ||
} | ||
}); | ||
}; | ||
var init = function init(options) { | ||
return new Promise(function (resolve) { | ||
if (!options || !options.appId) { | ||
throw new Error('You need to provide your OneSignal appId.'); | ||
throw new Error('You need to provide your OneSignal appId.'); | ||
} | ||
if (!document) { | ||
return; | ||
return; | ||
} | ||
injectSDKScript(); | ||
injectModuleScript(options); | ||
var timeout = setTimeout(function () { | ||
console.error(ONESIGNAL_NOT_SETUP_ERROR); | ||
injectScript(); | ||
setupOneSignalIfMissing(); | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].init(options); | ||
}); | ||
const timeout = setTimeout(() => { | ||
console.error(ONESIGNAL_NOT_SETUP_ERROR); | ||
}, MAX_TIMEOUT * 1000); | ||
OneSignal.push(function () { | ||
clearTimeout(timeout); | ||
processQueuedOneSignalFunctions(); | ||
resolve(); | ||
window["OneSignal"].push(() => { | ||
clearTimeout(timeout); | ||
processQueuedOneSignalFunctions(); | ||
resolve(); | ||
}); | ||
}); | ||
}; | ||
isOneSignalInitialized = true; | ||
}); | ||
function on(event, listener) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "on", | ||
args: arguments | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "on", | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].on(event, listener); | ||
}); | ||
return; | ||
} | ||
OneSignal.push(function () { | ||
OneSignal.on(event, listener); | ||
}); | ||
} | ||
function off(event, listener) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "off", | ||
args: arguments | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "off", | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].off(event, listener); | ||
}); | ||
return; | ||
} | ||
OneSignal.push(function () { | ||
OneSignal.off(event, listener); | ||
}); | ||
} | ||
function once(event, listener) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "once", | ||
args: arguments | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "once", | ||
args: arguments, | ||
}); | ||
return; | ||
} | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].once(event, listener); | ||
}); | ||
return; | ||
} | ||
OneSignal.push(function () { | ||
OneSignal.once(event, listener); | ||
}); | ||
} | ||
function isPushNotificationsEnabled(callback) { | ||
var _arguments = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "isPushNotificationsEnabled", | ||
args: _arguments, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.isPushNotificationsEnabled(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "isPushNotificationsEnabled", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].isPushNotificationsEnabled(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPrompt(options) { | ||
var _arguments2 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPrompt", | ||
args: _arguments2, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showHttpPrompt(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPrompt", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showHttpPrompt(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function registerForPushNotifications(options) { | ||
var _arguments3 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "registerForPushNotifications", | ||
args: _arguments3, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.registerForPushNotifications(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "registerForPushNotifications", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].registerForPushNotifications(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultNotificationUrl(url) { | ||
var _arguments4 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultNotificationUrl", | ||
args: _arguments4, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setDefaultNotificationUrl(url).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultNotificationUrl", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setDefaultNotificationUrl(url) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setDefaultTitle(title) { | ||
var _arguments5 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultTitle", | ||
args: _arguments5, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setDefaultTitle(title).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setDefaultTitle", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setDefaultTitle(title) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getTags(callback) { | ||
var _arguments6 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getTags", | ||
args: _arguments6, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getTags(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getTags", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getTags(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTag(key, value, callback) { | ||
var _arguments7 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTag", | ||
args: _arguments7, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.sendTag(key, value, callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTag", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].sendTag(key, value, callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendTags(tags, callback) { | ||
var _arguments8 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTags", | ||
args: _arguments8, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.sendTags(tags, callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendTags", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].sendTags(tags, callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTag(tag) { | ||
var _arguments9 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTag", | ||
args: _arguments9, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.deleteTag(tag).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTag", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].deleteTag(tag) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function deleteTags(tags, callback) { | ||
var _arguments10 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTags", | ||
args: _arguments10, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.deleteTags(tags, callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "deleteTags", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].deleteTags(tags, callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function addListenerForNotificationOpened(callback) { | ||
var _arguments11 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "addListenerForNotificationOpened", | ||
args: _arguments11, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.addListenerForNotificationOpened(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "addListenerForNotificationOpened", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].addListenerForNotificationOpened(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setSubscription(newSubscription) { | ||
var _arguments12 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSubscription", | ||
args: _arguments12, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setSubscription(newSubscription).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSubscription", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setSubscription(newSubscription) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showHttpPermissionRequest(options) { | ||
var _arguments13 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPermissionRequest", | ||
args: _arguments13, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showHttpPermissionRequest(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showHttpPermissionRequest", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showHttpPermissionRequest(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showNativePrompt() { | ||
var _arguments14 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showNativePrompt", | ||
args: _arguments14, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showNativePrompt().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showNativePrompt", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showNativePrompt() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSlidedownPrompt(options) { | ||
var _arguments15 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSlidedownPrompt", | ||
args: _arguments15, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showSlidedownPrompt(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSlidedownPrompt", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showSlidedownPrompt(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showCategorySlidedown(options) { | ||
var _arguments16 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showCategorySlidedown", | ||
args: _arguments16, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showCategorySlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showCategorySlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showCategorySlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSmsSlidedown(options) { | ||
var _arguments17 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsSlidedown", | ||
args: _arguments17, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showSmsSlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsSlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showSmsSlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showEmailSlidedown(options) { | ||
var _arguments18 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showEmailSlidedown", | ||
args: _arguments18, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showEmailSlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showEmailSlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showEmailSlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function showSmsAndEmailSlidedown(options) { | ||
var _arguments19 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsAndEmailSlidedown", | ||
args: _arguments19, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.showSmsAndEmailSlidedown(options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "showSmsAndEmailSlidedown", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].showSmsAndEmailSlidedown(options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getNotificationPermission(onComplete) { | ||
var _arguments20 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getNotificationPermission", | ||
args: _arguments20, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getNotificationPermission(onComplete).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getNotificationPermission", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getNotificationPermission(onComplete) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getUserId(callback) { | ||
var _arguments21 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getUserId", | ||
args: _arguments21, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getUserId(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getUserId(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getSubscription(callback) { | ||
var _arguments22 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSubscription", | ||
args: _arguments22, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getSubscription(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSubscription", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getSubscription(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setEmail(email, options) { | ||
var _arguments23 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setEmail", | ||
args: _arguments23, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setEmail(email, options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setEmail", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setEmail(email, options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setSMSNumber(smsNumber, options) { | ||
var _arguments24 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSMSNumber", | ||
args: _arguments24, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setSMSNumber(smsNumber, options).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setSMSNumber", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setSMSNumber(smsNumber, options) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function logoutEmail() { | ||
var _arguments25 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutEmail", | ||
args: _arguments25, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.logoutEmail().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutEmail", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].logoutEmail() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function logoutSMS() { | ||
var _arguments26 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutSMS", | ||
args: _arguments26, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.logoutSMS().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "logoutSMS", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].logoutSMS() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function setExternalUserId(externalUserId, authHash) { | ||
var _arguments27 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setExternalUserId", | ||
args: _arguments27, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.setExternalUserId(externalUserId, authHash).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "setExternalUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].setExternalUserId(externalUserId, authHash) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function removeExternalUserId() { | ||
var _arguments28 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "removeExternalUserId", | ||
args: _arguments28, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.removeExternalUserId().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "removeExternalUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].removeExternalUserId() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getExternalUserId() { | ||
var _arguments29 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getExternalUserId", | ||
args: _arguments29, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getExternalUserId().then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getExternalUserId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getExternalUserId() | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function provideUserConsent(consent) { | ||
var _arguments30 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "provideUserConsent", | ||
args: _arguments30, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.provideUserConsent(consent).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "provideUserConsent", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].provideUserConsent(consent) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getEmailId(callback) { | ||
var _arguments31 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getEmailId", | ||
args: _arguments31, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getEmailId(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getEmailId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getEmailId(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function getSMSId(callback) { | ||
var _arguments32 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSMSId", | ||
args: _arguments32, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.getSMSId(callback).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "getSMSId", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].getSMSId(callback) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
function sendOutcome(outcomeName, outcomeWeight) { | ||
var _arguments33 = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var oneSignal = window["OneSignal"] || null; | ||
if (!oneSignal) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendOutcome", | ||
args: _arguments33, | ||
promiseResolver: resolve | ||
}); | ||
return; | ||
} | ||
try { | ||
OneSignal.push(function () { | ||
OneSignal.sendOutcome(outcomeName, outcomeWeight).then(function (value) { | ||
return resolve(value); | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
if (!doesOneSignalExist()) { | ||
reactOneSignalFunctionQueue.push({ | ||
name: "sendOutcome", | ||
args: arguments, | ||
promiseResolver: resolve, | ||
}); | ||
return; | ||
} | ||
try { | ||
window["OneSignal"].push(() => { | ||
window["OneSignal"].sendOutcome(outcomeName, outcomeWeight) | ||
.then((value) => resolve(value)) | ||
.catch((error) => reject(error)); | ||
}); | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
var OneSignalReact = { | ||
init: init, | ||
on: on, | ||
off: off, | ||
once: once, | ||
isPushNotificationsEnabled: isPushNotificationsEnabled, | ||
showHttpPrompt: showHttpPrompt, | ||
registerForPushNotifications: registerForPushNotifications, | ||
setDefaultNotificationUrl: setDefaultNotificationUrl, | ||
setDefaultTitle: setDefaultTitle, | ||
getTags: getTags, | ||
sendTag: sendTag, | ||
sendTags: sendTags, | ||
deleteTag: deleteTag, | ||
deleteTags: deleteTags, | ||
addListenerForNotificationOpened: addListenerForNotificationOpened, | ||
setSubscription: setSubscription, | ||
showHttpPermissionRequest: showHttpPermissionRequest, | ||
showNativePrompt: showNativePrompt, | ||
showSlidedownPrompt: showSlidedownPrompt, | ||
showCategorySlidedown: showCategorySlidedown, | ||
showSmsSlidedown: showSmsSlidedown, | ||
showEmailSlidedown: showEmailSlidedown, | ||
showSmsAndEmailSlidedown: showSmsAndEmailSlidedown, | ||
getNotificationPermission: getNotificationPermission, | ||
getUserId: getUserId, | ||
getSubscription: getSubscription, | ||
setEmail: setEmail, | ||
setSMSNumber: setSMSNumber, | ||
logoutEmail: logoutEmail, | ||
logoutSMS: logoutSMS, | ||
setExternalUserId: setExternalUserId, | ||
removeExternalUserId: removeExternalUserId, | ||
getExternalUserId: getExternalUserId, | ||
provideUserConsent: provideUserConsent, | ||
getEmailId: getEmailId, | ||
getSMSId: getSMSId, | ||
sendOutcome: sendOutcome | ||
const OneSignalReact = { | ||
init, | ||
on, | ||
off, | ||
once, | ||
isPushNotificationsEnabled, | ||
showHttpPrompt, | ||
registerForPushNotifications, | ||
setDefaultNotificationUrl, | ||
setDefaultTitle, | ||
getTags, | ||
sendTag, | ||
sendTags, | ||
deleteTag, | ||
deleteTags, | ||
addListenerForNotificationOpened, | ||
setSubscription, | ||
showHttpPermissionRequest, | ||
showNativePrompt, | ||
showSlidedownPrompt, | ||
showCategorySlidedown, | ||
showSmsSlidedown, | ||
showEmailSlidedown, | ||
showSmsAndEmailSlidedown, | ||
getNotificationPermission, | ||
getUserId, | ||
getSubscription, | ||
setEmail, | ||
setSMSNumber, | ||
logoutEmail, | ||
logoutSMS, | ||
setExternalUserId, | ||
removeExternalUserId, | ||
getExternalUserId, | ||
provideUserConsent, | ||
getEmailId, | ||
getSMSId, | ||
sendOutcome, | ||
}; | ||
@@ -1127,0 +866,0 @@ |
{ | ||
"name": "react-onesignal", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "React OneSignal Module: Make it easy to integrate OneSignal with your React App!", | ||
@@ -13,3 +13,3 @@ "author": "rgomezp", | ||
"jsnext:main": "dist/index.es.js", | ||
"types": "./index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"engines": { | ||
@@ -16,0 +16,0 @@ "node": ">=8", |
@@ -11,3 +11,3 @@ import typescript from 'rollup-plugin-typescript2'; | ||
export default { | ||
input: './index.js', | ||
input: './index.ts', | ||
output: [ | ||
@@ -14,0 +14,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
202246
17
2849
1