Titanium

Titanium

OpenBack Titanium Mobile Module

To install OpenBack for your Titanium app, download the latest release binaries from Github then unzip in your application folder.

Adding the module

In your tiapp.xml, add the OpenBack module for android and/or iOS

<modules>
<module platform="iphone">com.openback</module>
<module platform="android">com.openback</module>
</modules>

Configure OpenBack

iOS Specific Settings

Edit the plist section of your tiapp.xml - most settings are optional. For a full list of available plist settings, check iOS PList documentation.

Example:

<ios>
...
<plist>
<dict>
...
<key>OpenBack</key>
<dict>
<key>OBKApplicationID</key>
<string>YOUR_APP_CODE</string>
</dict>
...
</dict>
</plist>
</ios>
warning

There seems to be a bug with the appcelerator build tools when settting an integer value to 0 like <integer>0</integer>, the tool transforms it into <integer/> which is invalid with xcode.

Android Specific Settings

Add a file named openback.json to the app/assets/android folder. After the build, it should appear in the assets/Resources folder in your build folder.

Refer to the config file for details.

Firebase

Firebase is also required for some features (instant message update, regular push messages). We recommend using this repo. Once you have Firebase setup, make sure to add the OpenBack services to handle messages in tiapp.xml:

<ti:app xmlns:ti="http://ti.appcelerator.org">
...
<android xmlns:android="http://schemas.android.com/apk/res/android">
<service android:name="com.openback.OpenBackFcmInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name="com.openback.OpenBackFcmMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</android>
...
</ti:app>

API

Include this line in your application source file(s) to to load the module.

var OpenBack = require('com.openback');

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(bool compliant)
Example
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(bool forgetUser)
Example
OpenBack.gdprForgetUser(true);

version

Returns the current OpenBack SDK version.

Definition
string version()
Example
var version = OpenBack.version();

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(string goal, int step, double value)
Example
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)
Example
OpenBack.setCustomTrigger(OpenBack.CUSTOM_TRIGGER_1, "customString");
OpenBack.setCustomTrigger(OpenBack.CUSTOM_TRIGGER_2, 123);
OpenBack.setCustomTrigger(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)
Example
OpenBack.setUserInfo({
'firstName': 'John',
'surname': 'Doe',
'emailAddress': 'john@doe.com'
});

Using Hyperloop

It is also possible to use Hyperloop to call the SDK directly.

Pros: Use Cocoapods and maven to stay up-to-date with SDKs.
Cons: The native API differs enough that you will need a lot of if ANDROID cases.

Enable Hyperloop

<module platform="android">hyperloop</module>
<module platform="iphone">hyperloop</module>

iOS

Add a Podfile

install! 'cocoapods',
:integrate_targets => false
platform :ios, '8.0'
target 'OpenBackSample' do
pod 'OpenBack'
end

Please refer to the iOS API for more info.

Android

Add a build.gradle

apply plugin: 'java'
repositories {
google()
mavenCentral()
maven { url 'https://maven.openback.com/public' }
}
dependencies {
implementation "com.openback:OpenBack:2.+"
}
task getDeps(type: Copy) {
from sourceSets.main.runtimeClasspath
exclude 'support-*' // The support libraries are packaged with Titanium already
into 'platform/android/' // Use "app/platform/android" for Alloy
}

Please refer to the android API for more info.