Cordova

cordova

OpenBack Cordova Plugin

In your project root folder, add the OpenBack plugin with:

cordova plugin add cordova-plugin-openback

The plugin sources and sample code are available on Github here.

Configure OpenBack

Edit your application config.xml with the following preferences:

Set your application code for each platform:

<preference name="com.openback.appCode" value="YOUR_APPLICATION_CODE" />

iOS Specific Configurations

All the values are optional except for the application code.

<platform name="ios">
<preference name="com.openback.appCode" value="YOUR_IOS_APPLICATION_CODE" />
<preference name="com.openback.enableAlertNotifications" value="true|false" />
<preference name="com.openback.enableRemoteNotifications" value="true|false" />
<preference name="com.openback.enableProximity" value="true|false" />
<preference name="com.openback.enableMicrophone" value="true|false" />
<preference name="com.openback.enableMotionCoprocessor" value="true|false" />
<preference name="com.openback.enableLocation" value="true|false" />
<preference name="com.openback.requestLocationAlwaysAuthorization" value="true|false" />
<preference name="com.openback.requestAlertNotificationsAuthorization" value="true|false" />
<preference name="com.openback.requestMotionCoprocessorAuthorization" value="true|false" />
<preference name="com.openback.requestMicrophoneAuthorization" value="true|false" />
<preference name="com.openback.minimumFetchInterval" value="0" />
<preference name="com.openback.notificationSound" value="YOUR_SOUND_FILE_NAME" />
<preference name="com.openback.logLevel" value="0" />
</platform>
PreferenceDescription
appCodeThe application code (Required)
enableAlertNotificationsEnable alert notifications (Optional - Default: true)
enableRemoteNotificationsEnable remote notifications (Optional - Default: true)
enableProximityEnable proximity sensor (Optional - Default: false)
enableMicrophoneEnable microphone (Optional - Default: false)
enableMotionCoprocessorEnable motion coprocessor (Optional - Default: false)
enableLocationEnable location (Optional - Default: false)
requestLocationAlwaysAuthorizationAllows OpenBack to prompt for location always authorization (Optional - Default: true)
requestAlertNotificationsAuthorizationAllows OpenBack to prompt for system alert notifications authorization (Optional - Default: true)
requestMotionCoprocessorAuthorizationAllows OpenBack to prompt for motion coprocessor access authorization (Optional - Default: true)
requestMicrophoneAuthorizationAllows OpenBack to prompt for microphone authorization (Optional - Default: true)
minimumFetchIntervalSet the minimim fetch interval in seconds (Optional - Default: 0). Use -1 for UIApplicationBackgroundFetchIntervalNever. Use 0 for UIApplicationBackgroundFetchIntervalMinimum
notificationSoundSet the notification sound (Optional - Default: UILocalNotificationDefaultSoundName)
logLevelThe debug log level (Opetional - Default: 0 - Up to 5 for verbose)

APNs for Push Notifications

Follow the information from the iOS Integration Guide.

Android Specific Configurations

OpenBack for android requires a minimum SDK of 16.

<platform name="android">
<preference name="android-minSdkVersion" value="16" />
<preference name="com.openback.appCode" value="msddgcjucx" />
<resource-file src="openback.json" target="assets/openback.json" />
</platform>

Edit openback.json

This file is used by the OpenBack SDK to set the notification icon for android 5+. Make sure the icon is copied to your android platform. You can customize the light, vibration pattern and sound too. For more info, check Android Integration guide.

The appCode should also be set in this file. It is used by the SDK to setup itself during an application upgrade.

When building for android, make sure the openback.json file is in the assets folder. If not, you might need to try with:

<resource-file src="openback.json" target="app/src/main/assets/openback.json" />

Firebase

Firebase is also required for some features (instant message update, regular push messages). We recommend using https://www.npmjs.com/package/cordova-plugin-firebase.

Android Manifest

Refer to the Android Integration guide to setup the manifest depending on the triggers the application will use. Include the extra permissions and receiver actions in the config.xml file of your application.

API

OpenBack SDK API is accessible in javascript via the window.openback interface.

The success and failure parameters are callback functions.

coppaCompliant

If your application needs COPPA to be enabled, set the COPPA compliant status with this function. If COPPA is enabled, messages will not run unless compliant is set to true.

Definition
coppaCompliant(compliant, success, failure)
Example
window.openback.coppaCompliant(true);

gdprForgetUser

When your user requests that all the data should be erased, set this value to true. It will inform the OpenBack server to remove all logs for the current user. All future logs will be erased after processing. If you wish to be fully GDPR complient, you also need to enable GDPR in your application settings on the OpenBack Dashboard.

Example:

Definition
gdprForgetUser(forgetUser, success, failure)
Definition
window.openback.gdprForgetUser(true);

Logging a Goal

At any point, you can log a goal that is associated with a message. Make sure to use the Goal code, not the Goal name.

Definition
logGoal(goal, step, value, success, failure)
Example
window.openback.logGoal("Test", 1, 12.3);

User Info & Custom Values

setCustomTrigger

Set a custom trigger value. Value can be string, integer or double.
For the trigger index, use CUSTOM_TRIGGER_1 to CUSTOM_TRIGGER_10.

Definition
setCustomTrigger(int trigger, id value, success, failure)
Example
window.openback.setCustomTrigger(window.openback.CUSTOM_TRIGGER_1, "customString");
window.openback.setCustomTrigger(window.openback.CUSTOM_TRIGGER_2, 123);
window.openback.setCustomTrigger(window.openback.CUSTOM_TRIGGER_3, 2.56);

setUserInfo

The application can pass some extra user information using a simple dictionary object by setting the following fields:

NameTypeDescription
addressLine1stringAddress line 1
addressLine2stringAddress line 2
advertisingIdstringAdvertising identifier set by the application
agestringAge
citystringCity
countrystringCountry
countryCodestringISO-2 country code
dateOfBirthstringDate of birth YYYY-MM-DD
emailAddressstringEmail Address
firstNamestringFirst name
genderstringGender
optInUpdatesstringOpting in for message updates "true"/"false"
phoneNumberstringPhone Number (international format)
postCodestringPostal code
professionstringProfession
statestringState
surnamestringSurname
titlestringTitle
identity1stringCustom user identifier 1
identity2stringCustom user identifier 2
identity3stringCustom user identifier 3
identity4stringCustom user identifier 4
identity5stringCustom user identifier 5
Note on Custom User Identifiers

Identity is for use with the OpenBack API. If you are not an OpenBack API client, don't use them. Identities are bound to the current OpenBack user, so changing any one of them will reset user and campaign usage. A usage example: when your application has users that can login and logout, you can set one of the Identity to a token used in your system to identify that user. Later on, using the OpenBack API, you can fetch details from that user.

Definition
setUserInfo(object, success, failure)
Example
window.openback.setUserInfo({
'firstName': 'John',
'surname': 'Doe',
'emailAddress': 'john@doe.com'
});

sdkVersion

Returns the current OpenBack SDK version.

Definition
string sdkVersion(success, failure)
Example
window.openback.version(function(v) {
console.log("Version: " + v);
});