Skip to content

Documentation Sections

This section is dedicated to the various functions available within the OpenBack SDK.

import com.openback.OpenBack;
import com.openback.UserInfoExtra;

Logging a Goal

To log a goal, first follow the steps on Goal Creation to set up your goal on the dashboard.

public static boolean logGoal(Context context, String goal, int step, double value)

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


OpenBack.logGoal(getApplicationContext(), "myGoalCode", 1, 102.5);
OpenBack.logGoal(applicationContext, "myGoalCode", 1, 102.5)

Available since: 2.3.0



public static void checkCampaignsNow(Context context)

Although it is highly recommended to let OpenBack library decide when to check the campaigns, you can force it right away.



Available since: 2.0.0


public static void coppaCompliant(Context context, boolean compliant)

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


OpenBack.coppaCompliant(getApplicationContext(), true);
OpenBack.coppaCompliant(applicationContext, true)

Available since: 2.3.1


public static int getAndroidMinSdkSupport()

Returns the minimum android SDK level supported by the library.


int minSdk = OpenBack.getAndroidMinSdkSupport();
val minSdk = OpenBack.getAndroidMinSdkSupport()

Available since: 2.0.0


public static String getAppCode(Context context)

Returns the currently set OpenBack app code.


String appCode = OpenBack.getAppCode(getApplicationContext());
val appCode = OpenBack.getAppCode(applicationContext)

Available since: 3.0.4


public static String getSdkVersion()

Returns the current OpenBack version.


String version = OpenBack.getSdkVersion();
val version = OpenBack.getSdkVersion()

Available since: 2.0.0


public static void gdprForgetUser(Context context, boolean forgetUser)

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.


OpenBack.gdprForgetUser(getApplicationContext(), true);
OpenBack.gdprForgetUser(applicationContext, true)

Available since: 2.3.0


public static boolean handleFcmMessage(Context context, Map<String, String> data)

When your application already uses Firebase message service class, call this method first to check if the message is intended for OpenBack.


public class YourFcmService extends FirebaseMessagingService {
    public void onMessageReceived(RemoteMessage remoteMessage) {
        if (!OpenBack.handleFcmMessage(getApplicationContext(), remoteMessage.getData())) {
            // FCM Message was not handled by OpenBack
class YourFcmService : FirebaseMessagingService() {
    override fun onMessageReceived(remoteMessage: RemoteMessage?) {
        if (!OpenBack.handleFcmMessage(applicationContext, remoteMessage.getData())) {
            // FCM Message was not handled by OpenBack

Available since: 2.0.0 - Parameters updated in 2.6.1 for optional dependencies


public static boolean isStarted(Context context)

Returns true if OpenBack is running.


BOOL started = OpenBack.isStarted(getApplicationContext());
val started = OpenBack.isStarted(applicationContext)

Available since: 2.2.0


public static void start(Config config) throws OpenBackException

Start the OpenBack library on the device. For best results, it should be called on the main thread in your application class onCreate().


OpenBack.start(new OpenBack.Config(context)

Available since: 2.0.0


public static void stop(Context context)

If you decide to opt-out of all notifications from OpenBack, call this function.
OpenBack will not run until start() is called again.



Available since: 2.2.0


public static void update(Config config) throws OpenBackException

Use this API to update the user info, including email / phone number / extra info. Updating the UserInfoExtra replaces the all previous values, so make sure to set all the fields needed each time.


UserInfoExtra userInfoExtra = new UserInfoExtra();
userInfoExtra.City = "Dublin";
OpenBack.update(new OpenBack.Config(context)
val info = UserInfoExtra()
info.City = "Dublin"

Available since: 2.0.0


public static void triggerEvent(Context context, String event, long delay)

Use this API to trigger an event. If a message matches your event and any other triggers, the message will be displayed after the given delay.

Delay is in seconds. If delay is a non-negative number, it will override the default value is set in the OpenBack Dashboard.


OpenBack.triggerEvent(getApplicationContext(), "MyEvent", 10);
OpenBack.triggerEvent(applicationContext, "MyEvent", 10)

Available since: 3.0.0


public static void cancelEvent(Context context, String event)

Use this API to cancel an event. Removes the displayed and scheduled notifications for the message set to use that event.


OpenBack.cancelEvent(getApplicationContext(), "MyEvent");
OpenBack.cancelEvent(applicationContext, "MyEvent")

Available since: 3.0.6


Config class is used when starting OpenBack. It's a simple container to wrap the initial data passed to the engine.

public Config(Context context)

Instantiate a Config object with the application context.

public Config setOpenBackAppCode(String openBackAppCode)

Set the OpenBack application Code.

This value is generated by the OpenBack Dashboard. If you are using openback.json with the "appCode" field, OpenBack can fill this value automatically so you don't need to call this method. This value is stored internally. If it changes, all the OpenBack data on the device will be erased.

public Config setGcmSenderId(String gcmSenderId)

Set the application GCM/FCM Sender ID.

If you are using gradle and google-services plugin, you don't need to call this method. The GCM/FCM sender ID will be retrieved from the application resources. This value is stored internally. If it changes, a new token will will be requested.

public Config setUserEmail(String email)

Set the user email.

This is optional but if you are using Intelligent Routing with emails, you need to provide a value. This value is stored internally.

public Config setUserMsisdn(String msisdn)

Set the user mobile phone number.

This is optional but if you are using Intelligent Routing with sms, you should to provide a value. If READ_PHONE_STATE is allowed, OpenBack will fill the value. This value is stored internally.

public Config setExtraUserInfo(UserInfoExtra userInfoExtra)

Set user extra info.

All the user info values are stored internally.

Custom Values & User Info

Custom values and user info (including Identity) can all be used for personalised content within messages. Custom values are used to segment/trigger messages for users. Identity is used when integrating the OpenBack Client API into your backend systems.

Custom Values

public final static int CUSTOM_TRIGGER_1
public final static int CUSTOM_TRIGGER_2
public final static int CUSTOM_TRIGGER_3
public final static int CUSTOM_TRIGGER_4
public final static int CUSTOM_TRIGGER_5
public final static int CUSTOM_TRIGGER_6
public final static int CUSTOM_TRIGGER_7
public final static int CUSTOM_TRIGGER_8
public final static int CUSTOM_TRIGGER_9
public final static int CUSTOM_TRIGGER_10


public static void setCustomTrigger(Context context, int triggerIndex, String value)
public static void setCustomTrigger(Context context, int triggerIndex, int value)
public static  void setCustomTrigger(Context context, int triggerIndex, float value)
public static  void setCustomTrigger(Context context, int triggerIndex, ArrayList<String> value)

Set a custom trigger value. Value can be String, int, float, or ArrayList<String>. For the trigger index, see Custom Triggers list.

The ArrayList<String> version is used with the CONTAINS operator on the dashboard.


OpenBack.setCustomTrigger(getApplicationContext(), OpenBack.CUSTOM_TRIGGER_1, "StringTest");
OpenBack.setCustomTrigger(getApplicationContext(), OpenBack.CUSTOM_TRIGGER_2, 42);
OpenBack.setCustomTrigger(getApplicationContext(), OpenBack.CUSTOM_TRIGGER_3, 1.12);
OpenBack.setCustomTrigger(applicationContext, OpenBack.CUSTOM_TRIGGER_1, "StringTest")
OpenBack.setCustomTrigger(applicationContext, OpenBack.CUSTOM_TRIGGER_2, 42)
OpenBack.setCustomTrigger(applicationContext, OpenBack.CUSTOM_TRIGGER_3, 1.12f)

Available since: 2.0.0

OpenBack typically supports up to 10 custom values, if you need more please discuss with OpenBack or email


public static Object getCustomTrigger(Context context, int triggerIndex)

Get the value associated with a custom trigger. Value can be String, int, float, or ArrayList<String>. For the trigger index, see Custom Triggers list.


Object value = OpenBack.getCustomTrigger(getApplicationContext(), OpenBack.CUSTOM_TRIGGER_1);
if (value instanceof Integer) {
    Integer myint = (Integer)value

Available since: 3.0.0


Class container for the user info.

Name Type Description
AddressLine1 String Address line 1
AddressLine2 String Address line 2
AdvertisingId String Advertising identifier set by the application
Age String Age
Country String Country
CountryCode String ISO-2 country code
State String State
DateOfBirth String Date of birth YYYY-MM-DD
FirstName String First name
Gender String Gender
OptInUpdates String Opting in for campaign updates "true"/"false"
PostCode String Postal code
Profession String Profession
Surname String Surname
Title String Title
City String City
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:
Identities are 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.