'use strict';
import { NativeModules, Platform } from 'react-native';
const LINKING_ERROR =
`The package 'react-native-verint-xm-sdk' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';
const FCP_DEFAULT_VERSION = "mobsdk"
const VerintXM = NativeModules.VerintXM
? NativeModules.VerintXM
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
function registerPlatform() {
VerintXM.setCPP("sdk-platform", "react-native");
}
/**
* @namespace VerintXM
*/
module.exports = {
/**
* Exposes the underlying Native Module.
*
* Useful for getting an object that NativeEventEmitter can wrap.
* @memberof VerintXM
*/
nativeModule: VerintXM,
/**
* Starts the Verint SDK. Accepts an optional config object (which must
* represent a valid Verint config, including a customerId). If no config
* is provided, then the native module will look for the config in a file called
* exp_configuration.json (which must be available to the native modules).
* @memberof VerintXM
*/
start(config) {
if (config) {
VerintXM.startWithConfigurationJson(JSON.stringify(config));
} else {
VerintXM.start();
}
registerPlatform();
},
/**
* Starts the SDK with the given configuration file in your native module.
* @memberof VerintXM
*/
startWithConfigurationFile(fileName) {
VerintXM.startWithConfigurationFile(fileName);
registerPlatform();
},
/**
* Starts the SDK with the given configuration JSON string.
* @memberof VerintXM
*/
startWithConfigurationJson(jsonString) {
VerintXM.startWithConfigurationJson(jsonString);
registerPlatform();
},
/**
* Starts the SDK with the given configuration URL.
* @memberof VerintXM
*/
startWithConfigurationUrl(urlString) {
VerintXM.startWithConfigurationUrl(urlString);
registerPlatform();
},
/**
* Starts the SDK using the given appId and version.
*
* If version is undefined, the default value is 'mobsdk'.
*
* Note: new configs may have been setup using a version of `1`. If this is true
* of your config, then you will need to supply this value explicitly.
*
* @memberof VerintXM
* @deprecated since v3.1.0. Use the Configurator instead. See: startWithSiteKey.
*/
startWithAppId(appId, version = FCP_DEFAULT_VERSION) {
VerintXM.startWithAppId(appId, version);
registerPlatform();
},
/**
* Starts the SDK with a configuration from the Configurator.
*
* @memberof VerintXM
*/
startWithSiteKey(siteKey) {
VerintXM.startWithSiteKey(siteKey);
registerPlatform();
},
/**
* Sets the remote configuration container.
*
* Note: when specifying a configuration container, this method must be called before
* starting the SDK.
*/
setConfigurationContainer(name) {
VerintXM.setConfigurationContainer(name);
},
/**
* Gets the remote configuration container
*
*/
getConfigurationContainer() {
return Promise.resolve(VerintXM.getConfigurationContainer());
},
/**
* Resets the SDK.
* @memberof VerintXM
*/
resetState() {
VerintXM.resetState();
},
/**
* Checks to see if the user is eligible for a survey.
* If the user meets trigger criteria *and* are in the sampling pool, the invitation is presented.
* Implementers must explicitly check for eligibility (the SDK does not do this automatically).
* @memberof VerintXM
*/
checkEligibility() {
VerintXM.checkEligibility();
},
/**
* Programmatically presents the invitation for a given survey ID (sid).
* @memberof VerintXM
* @deprecated since v3.2.0. Use Survey Management instead. See: showInviteForName.
*/
showInvite(surveyId) {
VerintXM.showInvite(surveyId);
},
/**
* Programmatically presents the survey for a given survey ID (sid).
* @memberof VerintXM
* @deprecated since v3.2.0. Use Survey Management instead. See: showSurveyForName.
*/
showSurvey(surveyId) {
VerintXM.showSurvey(surveyId);
},
/**
* Sets a Custom Passed Parameter (CPP) for the given key/value pair.
* CPPs are transmitted along with surveys upon submission.
* @memberof VerintXM
*/
setCPP(key, value) {
if (Array.isArray(value)) {
VerintXM.setCPPFromArray(key, value);
} else {
VerintXM.setCPP(key, value);
}
},
/**
* Appends a Custom Passed Parameter (CPP) for the list associated with the given key.
* If no list exists for the given key, then one will be created. If the key already
* contains a non-array value, then that value will be destroyed and a new list will
* be created.
*
* CPPs are transmitted along with surveys upon submission.
*/
appendCPP(key, value) {
VerintXM.appendCPP(key, value);
},
/**
* Gets the value of the Custom Passed Parameter (CPP) with the given key.
* @memberof VerintXM
*/
getCPP(key) {
return Promise.resolve(VerintXM.getCPP(key));
},
/**
* Removes the Custom Passed Parameter (CPP) with the given key.
* @memberof VerintXM
*/
removeCPP(key) {
VerintXM.removeCPP(key);
},
/**
* Gets an object containing all available Custom Passed Parameters (CPP) key/value pairs.
* @memberof VerintXM
*/
getAllCPPs() {
return Promise.resolve(VerintXM.getAllCPPs());
},
/**
* Manually increments the number of page views criteria counted by the Verint SDK.
* This can be useful when the user expected a new page to have been shown.
* @memberof VerintXM
*/
incrementPageViews() {
VerintXM.incrementPageViews();
},
/**
* Increments the count for the significant event with the given key.
* @memberof VerintXM
*/
incrementSignificantEvent(key) {
VerintXM.incrementSignificantEvent(key);
},
/**
* Sets the significant event count for a given key.
* @memberof VerintXM
*/
setSignificantEventCount(key, count) {
VerintXM.setSignificantEventCount(key, count);
},
/**
* Resets the significant event count for a given key.
* @memberof VerintXM
*/
resetSignificantEventCount(key) {
VerintXM.resetSignificantEventCount(key);
},
/**
* Resets all significant events.
* @memberof VerintXM
*/
resetSignificantEvents() {
VerintXM.resetSignificantEvents();
},
/**
* Programmatically cancels any pending invites for the user when the type is EXIT_INVITE or EXIT_SURVEY.
* @memberof VerintXM
*/
cancelPendingInvites() {
VerintXM.cancelPendingInvites();
},
/**
* Sets whether or not to enable debug logging.
* Debug logging prints useful state information to the console for inspection. By default, debug logging is disabled.
* @memberof VerintXM
*/
setDebugLogEnabled(enabled) {
VerintXM.setDebugLogEnabled(enabled);
},
/**
* Returns whether or not debug logging is enabled.
* @memberof VerintXM
*/
isDebugLogEnabled() {
return Promise.resolve(VerintXM.isDebugLogEnabled());
},
/**
* Sets whether or not to enable remote event logging.
* Event logging captures and transmits significant events that occur during the SDK life cycle.
* By default, event logging is enabled
* and it is highly recommended that this logging remain enabled in release builds.
* @memberof VerintXM
*/
setEventLogEnabled(enabled) {
VerintXM.setEventLogEnabled(enabled);
},
/**
* Returns the version of the SDK.
* @memberof VerintXM
*/
getVersion() {
return Promise.resolve(VerintXM.getVersion());
},
/**
* Toggles the pooling check.
* When debugging your implementation of the Verint SDK, it may be useful to disable the pooling check.
* This ensures that the invitation will always shows if the loyalty criteria has been fulfilled.
* @memberof VerintXM
*/
setSkipPoolingCheck(shouldSkip) {
VerintXM.setSkipPoolingCheck(shouldSkip);
},
/**
* Sets whether to enable custom invites.
*
* When enabled the SDK will send the following events, which the client should handle:
*
* - shouldShowCustomInvite
* - shouldHideCustomInvite
* - shouldSetInvalidInput
*
* @memberof VerintXM
*/
setCustomInviteEnabled(enabled, invitationMode) {
VerintXM.setCustomInviteEnabled(enabled, (invitationMode ? invitationMode.toUpperCase(invitationMode) : "IN_SESSION"));
},
/**
* Notifies the SDK that a custom invite has been accepted.
* You should call this method whenever a user accepts a custom invitation that you’ve presented.
* @memberof VerintXM
*/
customInviteAccepted() {
VerintXM.customInviteAccepted();
},
/**
* Notifies the SDK that a custom invite has been declined.
* You should call this method whenever a user declines a custom invitation that you’ve presented.
* @memberof VerintXM
*/
customInviteDeclined() {
VerintXM.customInviteDeclined();
},
/**
* Returns the user's contact details for the CONTACT invites.
* @memberof VerintXM
*/
getContactDetails(type) {
return Promise.resolve(VerintXM.getContactDetails(type));
},
/**
* Sets the user's contact details for the CONTACT invites. This method can be used to provide a user’s contact information, so that they do not need to enter it manually.
* When provided, the default invite skips the user input screen.
* @memberof VerintXM
*/
setContactDetails(details, type) {
VerintXM.setContactDetails(details, type);
},
/**
* Sets the preferred contact type for the CONTACT invites.
* @memberof VerintXM
*/
setPreferredContactType(type) {
VerintXM.setPreferredContactType(type);
},
/**
* Returns the preferred contact type for the CONTACT invites.
* @memberof VerintXM
*/
getPreferredContactType() {
return Promise.resolve(VerintXM.getPreferredContactType());
},
/**
* Returns all key/value pairs of the configured contact details for the CONTACT invites.
* @memberof VerintXM
*/
getAllContactDetails() {
return Promise.resolve(VerintXM.getAllContactDetails());
},
/**
* Presents the default Digital survey (the first one in the configuration).
* @memberof VerintXM
* @deprecated since v3.2.0. Digital surveys are no longer supported.
*/
showDigitalSurvey() {
VerintXM.showDigitalSurvey();
},
/**
* Presents the Digital survey for a given name.
* @memberof VerintXM
* @deprecated since v3.2.0. Digital surveys are no longer supported.
*/
showDigitalSurveyForName(surveyName) {
VerintXM.showDigitalSurveyForName(surveyName);
},
/**
* Checks if the default Digital Survey is enabled.
* @memberof VerintXM
* @deprecated since v3.2.0. Digital surveys are no longer supported.
*/
checkIfDigitalSurveyEnabled() {
VerintXM.checkIfDigitalSurveyEnabled();
},
/**
* Checks if a Digital survey is enabled for the given name.
* @memberof VerintXM
* @deprecated since v3.2.0. Digital surveys are no longer supported.
*/
checkIfDigitalSurveyEnabledForName(surveyName) {
VerintXM.checkIfDigitalSurveyEnabledForName(surveyName);
},
/**
* Returns all available Digital Survey names defined in the configuration.
* @memberof VerintXM
* @deprecated since v3.2.0. Digital surveys are no longer supported.
*/
getAvailableDigitalSurveyNames() {
return Promise.resolve(VerintXM.getAvailableDigitalSurveyNames());
},
// Survey Management
/**
* Programmatically presents the Survey Management invitation for a given name.
* @memberof VerintXM
*/
showInviteForName(name) {
VerintXM.showInviteForName(name);
},
/**
* Programmatically presents the Survey Management survey for a given name.
* @memberof VerintXM
*/
showSurveyForName(name) {
VerintXM.showSurveyForName(name);
}
};