Migrating to Android V4

This migration guide is for users that are moving from OpenBack's Android SDK V1 to <=V4.0.0. You can update to the latest version of OpenBack with the code below. Update your Gradle dependency to the version below.

dependencies {
implementation "com.openback:OpenBack:4.1.0"
}

After updating, the steps for migrating are as follows:

  • Remove the openback.json file and switch to our latest AndroidManifest.xml configuration.
  • Use the latest API calls from V4.

1 - Android Manifest Configuration

  • Remove the openback.json as this is no longer needed in V4.
  • You can now configure OpenBack in your application AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sample.app">
<application ...>
<activity android:name=".MainActivity">
...
</activity>
<meta-data android:name="com.openback.APP_CODE" android:value="YOUR_APP_CODE" />
<meta-data android:name="com.openback.AUTO_START" android:value="true" />
<meta-data android:name="com.openback.notification.ICON" android:resource="@drawable/ic_stat_name" />
</application>
</manifest>

Alternatively, if you do not provide an App Code in the plist, you can set it manually using the API.

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupOpenBack();
}
private void setupOpenBack() {
// Don't block the main thread in case OpenBack is not initialized
AsyncTask.execute(new Runnable() {
@Override
public void run() {
OpenBack.initialize(getApplicationContext())
// Optional if you already provide the app code in the manifest
OpenBack.setAppCode("YOUR_APP_CODE");
// Optional if you set auto start to true (default) in the manifest
OpenBack.start();
}
});
}
}

2 - Update Your API Calls

The Android SDK API has been updated to match the naming scheme of our iOS API for ease of use across both platforms. The following API calls have been changed in V4:

Config

warning

You no longer need to call the OpenBack Config as the configuration is completed in the Android Manifest.

3 - Project Configuration

Frameworks

In line with Apple's specifications, the OpenBack iOS V4 SDK has been split into several different modules depending on the required permissions. See below for the list of which modules you will need to include for certain signals:

iOS13+ Background Modes

Check Background fetch, Background processing and Remote notifications.

BackgroundModes

When background processing is enabled, add the following two permitted tasks to the Info.plist:

<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.openback.bgtask.refresh</string>
<string>com.openback.bgtask.check</string>
</array>

You're now ready to use V4 of the OpenBack SDK, see our full API documentation here or look at some of our other features below.

FeatureOverview
Signals & PermissionsAdd the required settings and permissions in your project settings for signals.
AttributesAttribute values can be set client side by your mobile app, and then used as personalized content within messages.
Custom SegmentsCustom Segments are set client side by your mobile app. They can be used to deliver a message based on the value set in your message campaign which is managed through the OpenBack Dashboard or Client APIs.
GoalsGoals can range from anything such as a user completing a signup process, to a user purchasing a product.
EventsAn event is an action at a particular moment in time for each user, which can then be used to deliver a notification. You can easily pass existing or new events to the OpenBack SDK client side, making advanced campaigns simple.
App InboxDeliver & manage messages in an inbox within your app – standalone, or as part of a notification.
TopicsMessage users that are subscribed to specific topics.
Advanced ConfigurationAdvanced OpenBack configuration parameters.
NotificationsCustomize the appearance of OpenBack notifications.