Extra features
Remote settings
The AppBrain SDK will regularly check for updates to “remote settings”. These are values you can set in the AppBrain developer dashboard for your app. With these settings, you can control your app remotely without having to launch a new update. The things that can be controlled range from very simple concepts, like the text of a welcome message, to turning major functionality in your app on or off.
All settings are String
key-value pairs. For example, to show a customizable welcome message:
// Get latest value for welcome_message, defaults to "Hello"
String welcomeMessage =
AppBrain.getSettings().get("welcome_message", "Hello");
// Show as toast
Toast.makeText(this, welcomeMessage, Toast.LENGTH_LONG).show();
If you run this code, it will show a toast with “Hello”. Now you can go to the AppBrain developer dashboard for your app and set the value for welcome_message
to e.g. “Hello from AppBrain”. Once the app has fetched the updated settings, it will show this new message instead.
Notes:
The SDK fetches the settings at most once per day, therefore it will use the old value if you have already started the app on this day. If you put the SDK in test mode, fetching will happen every 30 seconds. Alternatively, when testing, you can clear your app’s data in the Android settings to force a refresh.
Deleting a remote setting on the AppBrain dashboard will not clear the setting from existing installs of your app. Therefore, new installs won’t get a server-provided value anymore, but older installs will keep the last fetched setting. If you want to clear a setting on all devices, you can set it to an empty string or a
false
-like value.
Conversion event tracking
The AppBrain SDK allows you to track “conversion events” in your app. This can be any event you find useful to track, for instance a user signing up for your service, or a completed in-app payment. On the AppBrain developer dashboard you’re able to see the number of conversion events in your app per day. Every event can have an integer value you assign to it. The dashboard will show you the sum of the values of the events and the average event value. For an in-app payment you could for instance set the value to the number of cents of that was spent.
The type of event you track is given by a String
that you assign. The maximum length of this string is 20 characters.
Example code for tracking an in-app payment:
public void trackSuccessfulIabPayment(int cents) {
AppBrain.getAdvertiserService()
.sendConversionEvent("iab", cents);
}
In-app cloud alerts
A cloud alert is a message that you configure on the AppBrain developer dashboard, which will then be sent through the cloud to your app’s users. They will receive it the next time they open your app. Cloud alerts can be used in any app that includes the AppBrain SDK (version 10.1 or higher), no extra work required.
After creating and activating a cloud alert from the developer dashboard, it will by default show up in any Activity. To limit an alert to your app’s main activity, select the option Show only on main activity on the developer dashboard. Enabling this option will result in the alert only being shown in the activity that is marked as main launcher in your AndroidManifest.xml, e.g.:
<activity android:name=".ExampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
An advanced type of cloud alert which utilizes a WebView is also available. For more information see: WebView cloud alerts.