Skip to content

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>

Note: 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.

coppaCompliant(bool compliant)
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:

gdprForgetUser(bool forgetUser)
OpenBack.gdprForgetUser(true);

version

Returns the current OpenBack SDK version.

string version()
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.

logGoal(string goal, int step, double value)
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.

setCustomTrigger(int trigger, id value)
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:

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.

setUserInfo(object)
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.