tobostudio.com.batch.cordova
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "tobostudio.com.batch.cordova", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Plugin for the Batch SDK", | ||
@@ -5,0 +5,0 @@ "cordova": { |
336
www/batch.js
var BATCH_PLUGIN_NAME = "Batch"; | ||
var ACTION_SET_CONFIG = "setConfig"; | ||
var ACTION_START = "start"; | ||
var ACTION_UNLOCK_SETUP = "unlock.setup"; | ||
var ACTION_REDEEM_URL = "redeemURL"; | ||
var ACTION_REDEEM_CODE = "redeemCode"; | ||
var ACTION_RESTORE = "restore"; | ||
var ACTION_IS_DEV_MODE = "isDevMode"; | ||
var ACTION_GET_CUSTOM_USER_ID = "getCustomID"; | ||
var ACTION_SET_CUSTOM_USER_ID = "setCustomID"; | ||
var ACTION_GET_APP_LANGUAGE = "getAppLanguage"; | ||
var ACTION_SET_APP_LANGUAGE = "setAppLanguage"; | ||
var ACTION_GET_APP_REGION = "getAppRegion"; | ||
var ACTION_SET_APP_REGION = "setAppRegion"; | ||
var ACTION_PUSH_SETUP = "push.setup"; | ||
var ACTION_PUSH_GET_LAST_KNOWN_TOKEN = "push.getLastKnownPushToken"; | ||
var ACTION_SET_GCM_SENDER_ID = "push.setGCMSenderID"; | ||
var ACTION_SET_IOSNOTIF_TYPES = "push.setIOSNotifTypes"; | ||
var ACTION_SET_ANDROIDNOTIF_TYPES = "push.setAndroidNotifTypes"; | ||
var ACTION_REGISTER_NOTIFS = "push.register"; | ||
var ACTION_DISMISS_NOTIFS = "push.dismissNotifications"; | ||
var ACTION_CLEAR_BADGE = "push.clearBadge"; | ||
var ACTION_SET_CONFIG = "setConfig"; | ||
var ACTION_START = "start"; | ||
var ACTION_UNLOCK_SETUP = "unlock.setup"; | ||
var ACTION_REDEEM_URL = "redeemURL"; | ||
var ACTION_REDEEM_CODE = "redeemCode"; | ||
var ACTION_RESTORE = "restore"; | ||
var ACTION_IS_DEV_MODE = "isDevMode"; | ||
var ACTION_GET_CUSTOM_USER_ID = "getCustomID"; | ||
var ACTION_SET_CUSTOM_USER_ID = "setCustomID"; | ||
var ACTION_GET_APP_LANGUAGE = "getAppLanguage"; | ||
var ACTION_SET_APP_LANGUAGE = "setAppLanguage"; | ||
var ACTION_GET_APP_REGION = "getAppRegion"; | ||
var ACTION_SET_APP_REGION = "setAppRegion"; | ||
var ACTION_PUSH_SETUP = "push.setup"; | ||
var ACTION_PUSH_GET_LAST_KNOWN_TOKEN = "push.getLastKnownPushToken"; | ||
var ACTION_SET_GCM_SENDER_ID = "push.setGCMSenderID"; | ||
var ACTION_SET_IOSNOTIF_TYPES = "push.setIOSNotifTypes"; | ||
var ACTION_SET_ANDROIDNOTIF_TYPES = "push.setAndroidNotifTypes"; | ||
var ACTION_REGISTER_NOTIFS = "push.register"; | ||
var ACTION_DISMISS_NOTIFS = "push.dismissNotifications"; | ||
var ACTION_CLEAR_BADGE = "push.clearBadge"; | ||
var ACTION_USER_EDIT = "user.edit"; | ||
var ACTION_USER_TRACK_EVENT = "user.track.event"; | ||
var ACTION_USER_TRACK_TRANSACTION = "user.track.transaction"; | ||
var ACTION_USER_DATA_DEBUG = "user.data.debug"; | ||
var ACTION_USER_GET_INSTALLATION_ID = "user.getInstallationID"; | ||
var ACTION_USER_EDIT = "user.edit"; | ||
var ACTION_USER_TRACK_EVENT = "user.track.event"; | ||
var ACTION_USER_TRACK_TRANSACTION = "user.track.transaction"; | ||
var ACTION_USER_DATA_DEBUG = "user.data.debug"; | ||
var ACTION_USER_GET_INSTALLATION_ID = "user.getInstallationID"; | ||
var CALLBACK_LOG = "_log"; | ||
var CALLBACK_EVAL = "_eval"; | ||
var CALLBACK_DISPATCH_PUSH = "_dispatchPush"; | ||
var CALLBACK_ON_FAILURE = "onBridgeFailure"; | ||
var CALLBACK_ON_REDEEM_AUTOMATIC_OFFER = "onRedeemAutomaticOffer"; | ||
var CALLBACK_ON_REDEEM_URL_SUCCESS = "onRedeemURLSuccess"; | ||
var CALLBACK_ON_REDEEM_URL_FAILED = "onRedeemURLFailed"; | ||
var CALLBACK_ON_REDEEM_URL_CODEFOUND = "onRedeemURLCodeFound"; | ||
var CALLBACK_ON_REDEEM_CODE_SUCCESS = "onRedeemCodeSuccess"; | ||
var CALLBACK_ON_REDEEM_CODE_FAILED = "onRedeemCodeFailed"; | ||
var CALLBACK_ON_RESTORE_SUCCESS = "onRestoreSuccess"; | ||
var CALLBACK_ON_RESTORE_FAILED = "onRestoreFailed"; | ||
var CALLBACK_LOG = "_log"; | ||
var CALLBACK_EVAL = "_eval"; | ||
var CALLBACK_DISPATCH_PUSH = "_dispatchPush"; | ||
var CALLBACK_ON_FAILURE = "onBridgeFailure"; | ||
var CALLBACK_ON_REDEEM_AUTOMATIC_OFFER = "onRedeemAutomaticOffer"; | ||
var CALLBACK_ON_REDEEM_URL_SUCCESS = "onRedeemURLSuccess"; | ||
var CALLBACK_ON_REDEEM_URL_FAILED = "onRedeemURLFailed"; | ||
var CALLBACK_ON_REDEEM_URL_CODEFOUND = "onRedeemURLCodeFound"; | ||
var CALLBACK_ON_REDEEM_CODE_SUCCESS = "onRedeemCodeSuccess"; | ||
var CALLBACK_ON_REDEEM_CODE_FAILED = "onRedeemCodeFailed"; | ||
var CALLBACK_ON_RESTORE_SUCCESS = "onRestoreSuccess"; | ||
var CALLBACK_ON_RESTORE_FAILED = "onRestoreFailed"; | ||
var ACTION_INTERNAL_SETUP_CALLBACK = "_setupCallback"; | ||
var ACTION_INTERNAL_SETUP_CALLBACK = "_setupCallback"; | ||
var ATTRIBUTE_KEY_REGEXP = /^[a-zA-Z0-9_]{1,30}$/; | ||
var ATTRIBUTE_STRING_MAX_LENGTH = 64; | ||
var ATTRIBUTE_KEY_REGEXP = /^[a-zA-Z0-9_]{1,30}$/; | ||
var ATTRIBUTE_STRING_MAX_LENGTH = 64; | ||
@@ -53,2 +53,4 @@ var channel = require('cordova/channel'); | ||
var PENDING_PROMISES_REGISTER_FOR_REMOTE_NOTIFICATION = [] | ||
function isPlatformType(type) { | ||
@@ -70,3 +72,3 @@ return cordova.platformId.toLowerCase() === type; | ||
// It will need to be handled on a per-case basis | ||
cordova.exec(callback, null, BATCH_PLUGIN_NAME, "BA_" + method, args != null ? args : [{}]); | ||
cordova.exec(callback, null, BATCH_PLUGIN_NAME, "BA_" + method, args != null ? args : [{}]); | ||
} | ||
@@ -105,3 +107,3 @@ | ||
cordova.fireDocumentEvent('batchPushReceived', {"payload": pushPayload, "hasLandingMessage": hasLandingMessage}); | ||
cordova.fireDocumentEvent('batchPushReceived', { "payload": pushPayload, "hasLandingMessage": hasLandingMessage }); | ||
break; | ||
@@ -111,2 +113,5 @@ case CALLBACK_LOG: | ||
console.log(callbackData.message); | ||
if (callbackData.message.indexOf('Push token') > 0) { | ||
PENDING_PROMISES_REGISTER_FOR_REMOTE_NOTIFICATION.forEach((resolve) => resolve()) | ||
} | ||
break; | ||
@@ -151,3 +156,3 @@ case CALLBACK_EVAL: | ||
var listeners = batch._eventListeners[action] || []; | ||
listeners.forEach(function(listener) { | ||
listeners.forEach(function (listener) { | ||
listener(action, parameters); | ||
@@ -178,11 +183,11 @@ }); | ||
/** | ||
* Setup Batch's callback so that the plugin gets a callbackId to send events to the app using the SDK. | ||
* For private use only. | ||
* @private | ||
*/ | ||
_setupCallback:function() { | ||
/** | ||
* Setup Batch's callback so that the plugin gets a callbackId to send events to the app using the SDK. | ||
* For private use only. | ||
* @private | ||
*/ | ||
_setupCallback: function () { | ||
// Don't call sendToBridge because we don't want to have the BA_ prefix | ||
cordova.exec(handleCallback, null, BATCH_PLUGIN_NAME, ACTION_INTERNAL_SETUP_CALLBACK, [{}]); | ||
}, | ||
}, | ||
@@ -196,3 +201,3 @@ /** | ||
*/ | ||
on:function(event, listener) { | ||
on: function (event, listener) { | ||
if (typeof event !== "string") { | ||
@@ -217,3 +222,3 @@ writeBatchLog(false, "Event name must be a string if supplied"); | ||
*/ | ||
off:function(event) { | ||
off: function (event) { | ||
if (typeof event === "undefined") { | ||
@@ -231,5 +236,5 @@ this._eventListeners = {}; | ||
/** | ||
* Set Batch's config. you're required to call this before start | ||
* | ||
/** | ||
* Set Batch's config. you're required to call this before start | ||
* | ||
* The config object is a literal that has 4 variables | ||
@@ -245,4 +250,4 @@ * {?string} androidAPIKey Your Android API Key (default null) | ||
* @return {batch} Returns itself so you can chain calls | ||
*/ | ||
setConfig:function(config) { | ||
*/ | ||
setConfig: function (config) { | ||
if (typeof config !== "object") { | ||
@@ -255,6 +260,6 @@ writeBatchLog(false, "Config must be an object."); | ||
var baseConfig = { | ||
"androidAPIKey":null, | ||
"iOSAPIKey":null, | ||
"canUseIDFA":true, | ||
"canUseAndroidID":true | ||
"androidAPIKey": null, | ||
"iOSAPIKey": null, | ||
"canUseIDFA": true, | ||
"canUseAndroidID": true | ||
}; | ||
@@ -274,3 +279,3 @@ | ||
return this; | ||
}, | ||
}, | ||
@@ -280,3 +285,3 @@ /** | ||
*/ | ||
start:function() { | ||
start: function () { | ||
if (this._config === null) { | ||
@@ -295,10 +300,10 @@ writeBatchLog(false, "You must call setConfig before calling start."); | ||
sendToBridge(null, ACTION_SET_CONFIG, [{ | ||
'APIKey':apiKey, | ||
'useIDFA':this._config.canUseIDFA === true, // Handles "undefined" or "null" | ||
'useAndroidID':this._config.useAndroidID === true | ||
'APIKey': apiKey, | ||
'useIDFA': this._config.canUseIDFA === true, // Handles "undefined" or "null" | ||
'useAndroidID': this._config.useAndroidID === true | ||
}]); | ||
sendToBridge(null, ACTION_START, null); | ||
sendToBridge(null, ACTION_START, null); | ||
return this; | ||
}, | ||
}, | ||
@@ -318,3 +323,3 @@ /** | ||
*/ | ||
getCustomIdentifier: function(resultCallback) { | ||
getCustomIdentifier: function (resultCallback) { | ||
sendToBridge(resultCallback, ACTION_GET_CUSTOM_USER_ID, null); | ||
@@ -330,3 +335,3 @@ }, | ||
*/ | ||
setCustomIdentifier: function(customIdentifier) { | ||
setCustomIdentifier: function (customIdentifier) { | ||
if (customIdentifier !== null && typeof customIdentifier !== "string") { | ||
@@ -336,3 +341,3 @@ writeBatchLog(false, "Custom identifier must be a string or null"); | ||
} | ||
sendToBridge(null, ACTION_SET_CUSTOM_USER_ID, [{"customID": customIdentifier}]); | ||
sendToBridge(null, ACTION_SET_CUSTOM_USER_ID, [{ "customID": customIdentifier }]); | ||
}, | ||
@@ -346,3 +351,3 @@ | ||
*/ | ||
getLanguage: function(resultCallback) { | ||
getLanguage: function (resultCallback) { | ||
sendToBridge(resultCallback, ACTION_GET_APP_LANGUAGE, null); | ||
@@ -357,3 +362,3 @@ }, | ||
*/ | ||
setLanguage: function(language) { | ||
setLanguage: function (language) { | ||
if (language !== null && typeof language !== "string") { | ||
@@ -363,3 +368,3 @@ writeBatchLog(false, "Language must be a string or null"); | ||
} | ||
sendToBridge(null, ACTION_SET_APP_LANGUAGE, [{"language": language}]); | ||
sendToBridge(null, ACTION_SET_APP_LANGUAGE, [{ "language": language }]); | ||
}, | ||
@@ -373,3 +378,3 @@ | ||
*/ | ||
getRegion: function(resultCallback) { | ||
getRegion: function (resultCallback) { | ||
sendToBridge(resultCallback, ACTION_GET_APP_REGION, null); | ||
@@ -384,3 +389,3 @@ }, | ||
*/ | ||
setRegion: function(region) { | ||
setRegion: function (region) { | ||
if (region !== null && typeof region !== "string") { | ||
@@ -390,3 +395,3 @@ writeBatchLog(false, "Region must be a string or null"); | ||
} | ||
sendToBridge(null, ACTION_SET_APP_REGION, [{"region": region}]); | ||
sendToBridge(null, ACTION_SET_APP_REGION, [{ "region": region }]); | ||
} | ||
@@ -400,3 +405,3 @@ }, | ||
*/ | ||
push: { | ||
push: { | ||
@@ -431,3 +436,3 @@ /** | ||
*/ | ||
setup:function() { | ||
setup: function () { | ||
sendToBridge(null, ACTION_PUSH_SETUP, null); | ||
@@ -442,6 +447,6 @@ return this; | ||
*/ | ||
setGCMSenderID:function(senderID) { | ||
sendToBridge(null, ACTION_SET_GCM_SENDER_ID, [{'senderID':senderID}]); | ||
setGCMSenderID: function (senderID) { | ||
sendToBridge(null, ACTION_SET_GCM_SENDER_ID, [{ 'senderID': senderID }]); | ||
return this; | ||
}, | ||
}, | ||
@@ -452,7 +457,10 @@ /** | ||
*/ | ||
registerForRemoteNotifications:function() { | ||
registerForRemoteNotifications: function () { | ||
sendToBridge(null, ACTION_REGISTER_NOTIFS, null); | ||
return this; | ||
}, | ||
return new Promise((resolve, reject) => { | ||
PENDING_PROMISES_REGISTER_FOR_REMOTE_NOTIFICATION.push(resolve) | ||
}); | ||
}, | ||
/** | ||
@@ -464,3 +472,3 @@ * Change the used remote notification types on Android. (Ex: sound, vibrate, alert) | ||
*/ | ||
setAndroidNotificationTypes:function(notifTypes) { | ||
setAndroidNotificationTypes: function (notifTypes) { | ||
if (typeof notifTypes !== "number") { | ||
@@ -470,3 +478,3 @@ writeBatchLog(false, "notifTypes must be a number (of the AndroidNotificationTypes enum)"); | ||
} | ||
sendToBridge(null, ACTION_SET_ANDROIDNOTIF_TYPES, [{'notifTypes':notifTypes}]); | ||
sendToBridge(null, ACTION_SET_ANDROIDNOTIF_TYPES, [{ 'notifTypes': notifTypes }]); | ||
return this; | ||
@@ -481,3 +489,3 @@ }, | ||
*/ | ||
setiOSNotificationTypes:function(notifTypes) { | ||
setiOSNotificationTypes: function (notifTypes) { | ||
if (typeof notifTypes !== "number") { | ||
@@ -487,3 +495,3 @@ writeBatchLog(false, "notifTypes must be a number (of the iOSNotificationTypes enum)"); | ||
} | ||
sendToBridge(null, ACTION_SET_IOSNOTIF_TYPES, [{'notifTypes':notifTypes}]); | ||
sendToBridge(null, ACTION_SET_IOSNOTIF_TYPES, [{ 'notifTypes': notifTypes }]); | ||
return this; | ||
@@ -496,3 +504,3 @@ }, | ||
*/ | ||
clearBadge:function() { | ||
clearBadge: function () { | ||
sendToBridge(null, ACTION_CLEAR_BADGE, null); | ||
@@ -506,3 +514,3 @@ return this; | ||
*/ | ||
dismissNotifications:function() { | ||
dismissNotifications: function () { | ||
sendToBridge(null, ACTION_DISMISS_NOTIFS, null); | ||
@@ -525,6 +533,6 @@ return this; | ||
*/ | ||
getLastKnownPushToken: function(resultCallback) { | ||
getLastKnownPushToken: function (resultCallback) { | ||
sendToBridge(resultCallback, ACTION_PUSH_GET_LAST_KNOWN_TOKEN, null); | ||
} | ||
}, | ||
}, | ||
@@ -541,3 +549,3 @@ /** | ||
*/ | ||
setup:function() { | ||
setup: function () { | ||
sendToBridge(null, ACTION_UNLOCK_SETUP, null); | ||
@@ -552,3 +560,3 @@ return this; | ||
*/ | ||
redeemCode:function(code) { | ||
redeemCode: function (code) { | ||
if (typeof code !== "string") { | ||
@@ -558,3 +566,3 @@ writeBatchLog(false, "The code to redeem must be a string."); | ||
} | ||
sendToBridge(null, ACTION_REDEEM_CODE, [{"code": code}]); | ||
sendToBridge(null, ACTION_REDEEM_CODE, [{ "code": code }]); | ||
return this; | ||
@@ -568,3 +576,3 @@ }, | ||
*/ | ||
restore:function() { | ||
restore: function () { | ||
sendToBridge(null, ACTION_RESTORE, null); | ||
@@ -586,3 +594,3 @@ return this; | ||
*/ | ||
getInstallationID:function(resultCallback) { | ||
getInstallationID: function (resultCallback) { | ||
sendToBridge(resultCallback, ACTION_USER_GET_INSTALLATION_ID, null); | ||
@@ -595,3 +603,3 @@ return this; | ||
*/ | ||
getEditor:function() { | ||
getEditor: function () { | ||
return new BatchUserDataEditor(); | ||
@@ -602,3 +610,3 @@ }, | ||
*/ | ||
printDebugInformation:function() { | ||
printDebugInformation: function () { | ||
sendToBridge(null, ACTION_USER_DATA_DEBUG, null); | ||
@@ -614,4 +622,4 @@ return this; | ||
*/ | ||
trackEvent:function(name, label, data) { | ||
if (ATTRIBUTE_KEY_REGEXP.test(event||"")) { | ||
trackEvent: function (name, label, data) { | ||
if (ATTRIBUTE_KEY_REGEXP.test(event || "")) { | ||
writeBatchLog(false, "BatchUserDataEditor - Invalid event name. Please make sure that the name is made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters. Ignoring event '" + name + "'"); | ||
@@ -621,3 +629,3 @@ return this; | ||
var parameters = {"name": name}; | ||
var parameters = { "name": name }; | ||
@@ -649,3 +657,3 @@ if (label instanceof String || typeof label === "string") { | ||
*/ | ||
trackTransaction:function(amount, data) { | ||
trackTransaction: function (amount, data) { | ||
@@ -662,3 +670,3 @@ if (typeof amount === "undefined") { | ||
var parameters = {"amount": amount}; | ||
var parameters = { "amount": amount }; | ||
@@ -700,3 +708,3 @@ if (typeof data === "object") { | ||
*/ | ||
BatchUserDataEditor = function() { | ||
BatchUserDataEditor = function () { | ||
this._operationQueue = []; | ||
@@ -712,4 +720,4 @@ }; | ||
*/ | ||
BatchUserDataEditor.prototype._enqueueOperation = function(operation, args) { | ||
var operationObject = {"operation": operation}; | ||
BatchUserDataEditor.prototype._enqueueOperation = function (operation, args) { | ||
var operationObject = { "operation": operation }; | ||
@@ -733,3 +741,3 @@ if (typeof args !== "undefined") { | ||
*/ | ||
BatchUserDataEditor.prototype.setLanguage = function(language) { | ||
BatchUserDataEditor.prototype.setLanguage = function (language) { | ||
if (typeof language !== "string" && language !== null) { | ||
@@ -740,3 +748,3 @@ writeBatchLog(false, "BatchUserDataEditor - Language must be a string or null"); | ||
this._enqueueOperation(BatchUserDataOperation.SET_LANGUAGE, {"value": language}); | ||
this._enqueueOperation(BatchUserDataOperation.SET_LANGUAGE, { "value": language }); | ||
@@ -751,3 +759,3 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.setRegion = function(region) { | ||
BatchUserDataEditor.prototype.setRegion = function (region) { | ||
if (typeof region !== "string" && region !== null) { | ||
@@ -758,3 +766,3 @@ writeBatchLog(false, "BatchUserDataEditor - Region must be a string or null"); | ||
this._enqueueOperation(BatchUserDataOperation.SET_REGION, {"value": region}); | ||
this._enqueueOperation(BatchUserDataOperation.SET_REGION, { "value": region }); | ||
@@ -770,3 +778,3 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.setIdentifier = function(identifier) { | ||
BatchUserDataEditor.prototype.setIdentifier = function (identifier) { | ||
if (typeof identifier !== "string" && identifier !== null) { | ||
@@ -777,3 +785,3 @@ writeBatchLog(false, "BatchUserDataEditor - Identifier must be a string or null"); | ||
this._enqueueOperation(BatchUserDataOperation.SET_IDENTIFIER, {"value": identifier}); | ||
this._enqueueOperation(BatchUserDataOperation.SET_IDENTIFIER, { "value": identifier }); | ||
@@ -789,4 +797,4 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.setAttribute = function(key, value) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(key||"")) { | ||
BatchUserDataEditor.prototype.setAttribute = function (key, value) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(key || "")) { | ||
writeBatchLog(false, "BatchUserDataEditor - Invalid key. Please make sure that the key is made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters. Ignoring attribute '" + key + "'"); | ||
@@ -806,3 +814,3 @@ return this; | ||
var operationData = {"value": value, "key": key}; | ||
var operationData = { "value": value, "key": key }; | ||
@@ -822,3 +830,3 @@ // Lets guess the type | ||
if (value.length == 0 || value.length > ATTRIBUTE_STRING_MAX_LENGTH) { | ||
writeBatchLog(false, "BatchUserDataEditor - String attributes can't be empty or longer than " + ATTRIBUTE_STRING_MAX_LENGTH +" characters. Ignoring attribute '" + key + "'."); | ||
writeBatchLog(false, "BatchUserDataEditor - String attributes can't be empty or longer than " + ATTRIBUTE_STRING_MAX_LENGTH + " characters. Ignoring attribute '" + key + "'."); | ||
return this; | ||
@@ -844,4 +852,4 @@ } | ||
*/ | ||
BatchUserDataEditor.prototype.removeAttribute = function(key) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(key||"")) { | ||
BatchUserDataEditor.prototype.removeAttribute = function (key) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(key || "")) { | ||
writeBatchLog(false, "BatchUserDataEditor - Invalid key. Please make sure that the key is made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters. Ignoring attribute '" + key + "'"); | ||
@@ -851,3 +859,3 @@ return this; | ||
this._enqueueOperation(BatchUserDataOperation.REMOVE_ATTRIBUTE, {"key": key}); | ||
this._enqueueOperation(BatchUserDataOperation.REMOVE_ATTRIBUTE, { "key": key }); | ||
@@ -861,3 +869,3 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.clearAttributes = function() { | ||
BatchUserDataEditor.prototype.clearAttributes = function () { | ||
this._enqueueOperation(BatchUserDataOperation.CLEAR_ATTRIBUTES, {}); | ||
@@ -874,3 +882,3 @@ | ||
*/ | ||
BatchUserDataEditor.prototype.addTag = function(collection, tag) { | ||
BatchUserDataEditor.prototype.addTag = function (collection, tag) { | ||
if (typeof collection !== "string" && !(collection instanceof String)) { | ||
@@ -881,3 +889,3 @@ writeBatchLog(false, "BatchUserDataEditor - Collection argument must be a string"); | ||
if (!ATTRIBUTE_KEY_REGEXP.test(collection||"")) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(collection || "")) { | ||
writeBatchLog(false, "BatchUserDataEditor - Invalid collection. Please make sure that the collection is made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters. Ignoring collection '" + collection + "'"); | ||
@@ -902,3 +910,3 @@ return this; | ||
this._enqueueOperation(BatchUserDataOperation.ADD_TAG, {"collection": collection, "tag": tag}); | ||
this._enqueueOperation(BatchUserDataOperation.ADD_TAG, { "collection": collection, "tag": tag }); | ||
@@ -914,3 +922,3 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.removeTag = function(collection, tag) { | ||
BatchUserDataEditor.prototype.removeTag = function (collection, tag) { | ||
if (typeof collection !== "string" && !(collection instanceof String)) { | ||
@@ -921,3 +929,3 @@ writeBatchLog(false, "BatchUserDataEditor - Collection argument must be a string"); | ||
if (!ATTRIBUTE_KEY_REGEXP.test(collection||"")) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(collection || "")) { | ||
writeBatchLog(false, "BatchUserDataEditor - Invalid collection. Please make sure that the collection is made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters. Ignoring collection '" + collection + "'"); | ||
@@ -941,3 +949,3 @@ return this; | ||
this._enqueueOperation(BatchUserDataOperation.REMOVE_TAG, {"collection": collection, "tag": tag}); | ||
this._enqueueOperation(BatchUserDataOperation.REMOVE_TAG, { "collection": collection, "tag": tag }); | ||
@@ -951,3 +959,3 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.clearTags = function() { | ||
BatchUserDataEditor.prototype.clearTags = function () { | ||
this._enqueueOperation(BatchUserDataOperation.CLEAR_TAGS, {}); | ||
@@ -963,3 +971,3 @@ | ||
*/ | ||
BatchUserDataEditor.prototype.clearTagCollection = function(collection) { | ||
BatchUserDataEditor.prototype.clearTagCollection = function (collection) { | ||
if (typeof collection !== "string" && !(collection instanceof String)) { | ||
@@ -970,3 +978,3 @@ writeBatchLog(false, "BatchUserDataEditor - Collection argument must be a string"); | ||
if (!ATTRIBUTE_KEY_REGEXP.test(collection||"")) { | ||
if (!ATTRIBUTE_KEY_REGEXP.test(collection || "")) { | ||
writeBatchLog(false, "BatchUserDataEditor - Invalid collection. Please make sure that the collection is made of letters, underscores and numbers only (a-zA-Z0-9_). It also can't be longer than 30 characters. Ignoring collection '" + collection + "'"); | ||
@@ -976,3 +984,3 @@ return this; | ||
this._enqueueOperation(BatchUserDataOperation.CLEAR_TAG_COLLECTION, {"collection": collection}); | ||
this._enqueueOperation(BatchUserDataOperation.CLEAR_TAG_COLLECTION, { "collection": collection }); | ||
@@ -986,3 +994,3 @@ return this; | ||
*/ | ||
BatchUserDataEditor.prototype.save = function() { | ||
BatchUserDataEditor.prototype.save = function () { | ||
sendToBridge(null, ACTION_USER_EDIT, [{ | ||
@@ -999,6 +1007,6 @@ 'operations': this._operationQueue | ||
BatchUserDataEditorStub = function() {}; | ||
BatchUserDataEditorStub = function () { }; | ||
for (var editorPrototypeFunction in BatchUserDataEditor.prototype) { | ||
//noinspection JSUnfilteredForInLoop | ||
BatchUserDataEditorStub.prototype[editorPrototypeFunction] = function() { return this; }; | ||
BatchUserDataEditorStub.prototype[editorPrototypeFunction] = function () { return this; }; | ||
} | ||
@@ -1013,3 +1021,3 @@ | ||
// Setup the callback ASAP | ||
channel.onCordovaReady.subscribe(function() { | ||
channel.onCordovaReady.subscribe(function () { | ||
batch._setupCallback(); | ||
@@ -1024,14 +1032,14 @@ }); | ||
module.exports = { | ||
_setupCallback:function () {}, | ||
on:function () {return this;}, | ||
off:function () {return this;}, | ||
setConfig:function () {return this;}, | ||
start:function () {return this;}, | ||
_setupCallback: function () { }, | ||
on: function () { return this; }, | ||
off: function () { return this; }, | ||
setConfig: function () { return this; }, | ||
start: function () { return this; }, | ||
userProfile: { | ||
getCustomIdentifier:function() {}, | ||
setCustomIdentifier:function() {}, | ||
getLanguage:function() {}, | ||
setLanguage:function() {}, | ||
getRegion:function() {}, | ||
setRegion:function() {} | ||
getCustomIdentifier: function () { }, | ||
setCustomIdentifier: function () { }, | ||
getLanguage: function () { }, | ||
setLanguage: function () { }, | ||
getRegion: function () { }, | ||
setRegion: function () { } | ||
}, | ||
@@ -1041,21 +1049,21 @@ push: { | ||
iOSNotificationTypes: batch.push.iOSNotificationTypes, | ||
setup:function () {return this;}, | ||
setGCMSenderID:function () {return this;}, | ||
registerForRemoteNotifications:function () {return this;}, | ||
setAndroidNotificationTypes:function () {return this;}, | ||
setiOSNotificationTypes:function () {return this;}, | ||
clearBadge:function () {return this;}, | ||
dismissNotifications:function () {return this;}, | ||
getLastKnownPushToken:function () {return this;} | ||
setup: function () { return this; }, | ||
setGCMSenderID: function () { return this; }, | ||
registerForRemoteNotifications: function () { return this; }, | ||
setAndroidNotificationTypes: function () { return this; }, | ||
setiOSNotificationTypes: function () { return this; }, | ||
clearBadge: function () { return this; }, | ||
dismissNotifications: function () { return this; }, | ||
getLastKnownPushToken: function () { return this; } | ||
}, | ||
unlock: { | ||
setup:function () {return this;}, | ||
redeemCode:function () {return this;}, | ||
restore:function () {return this;} | ||
setup: function () { return this; }, | ||
redeemCode: function () { return this; }, | ||
restore: function () { return this; } | ||
}, | ||
user: { | ||
getInstallationID:function () {return this;}, | ||
getEditor:function () {return new BatchUserDataEditorStub();}, | ||
trackEvent:function () {return this;}, | ||
trackTransaction:function () {return this;}, | ||
getInstallationID: function () { return this; }, | ||
getEditor: function () { return new BatchUserDataEditorStub(); }, | ||
trackEvent: function () { return this; }, | ||
trackTransaction: function () { return this; }, | ||
} | ||
@@ -1088,2 +1096,2 @@ } | ||
* @param {?string} result Last known token | ||
*/ | ||
*/ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
897
14438373