Cordova
OpenBack Cordova Plugin
In your project root folder, add the OpenBack plugin with:
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:
iOS Specific Configurations
All the values are optional except for the application code.
Preference | Description |
---|---|
appCode | The application code (Required) |
enableAlertNotifications | Enable alert notifications (Optional - Default: true) |
enableRemoteNotifications | Enable remote notifications (Optional - Default: true) |
enableProximity | Enable proximity sensor (Optional - Default: false) |
enableMicrophone | Enable microphone (Optional - Default: false) |
enableMotionCoprocessor | Enable motion coprocessor (Optional - Default: false) |
enableLocation | Enable location (Optional - Default: false) |
requestLocationAlwaysAuthorization | Allows OpenBack to prompt for location always authorization (Optional - Default: true) |
requestAlertNotificationsAuthorization | Allows OpenBack to prompt for system alert notifications authorization (Optional - Default: true) |
requestMotionCoprocessorAuthorization | Allows OpenBack to prompt for motion coprocessor access authorization (Optional - Default: true) |
requestMicrophoneAuthorization | Allows OpenBack to prompt for microphone authorization (Optional - Default: true) |
minimumFetchInterval | Set the minimim fetch interval in seconds (Optional - Default: 0). Use -1 for UIApplicationBackgroundFetchIntervalNever. Use 0 for UIApplicationBackgroundFetchIntervalMinimum |
notificationSound | Set the notification sound (Optional - Default: UILocalNotificationDefaultSoundName) |
logLevel | The 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.
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:
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.
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:
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.
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.
setUserInfo
The application can pass some extra user information using a simple dictionary object by setting the following fields:
Name | Type | Description |
---|---|---|
addressLine1 | string | Address line 1 |
addressLine2 | string | Address line 2 |
advertisingId | string | Advertising identifier set by the application |
age | string | Age |
city | string | City |
country | string | Country |
countryCode | string | ISO-2 country code |
dateOfBirth | string | Date of birth YYYY-MM-DD |
emailAddress | string | Email Address |
firstName | string | First name |
gender | string | Gender |
optInUpdates | string | Opting in for message updates "true"/"false" |
phoneNumber | string | Phone Number (international format) |
postCode | string | Postal code |
profession | string | Profession |
state | string | State |
surname | string | Surname |
title | string | Title |
identity1 | string | Custom user identifier 1 |
identity2 | string | Custom user identifier 2 |
identity3 | string | Custom user identifier 3 |
identity4 | string | Custom user identifier 4 |
identity5 | string | Custom 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.
sdkVersion
Returns the current OpenBack SDK version.