Fetch live content (Android)
Learn how to fetch and display live content in your Android app using the Blueshift SDK.
Live content enables you to deliver personalized content to users in your Android app. The SDK provides methods to fetch content from slots configured in your Blueshift dashboard.
Prerequisites
- SDK setup
- User identification (email, customer ID, or device ID)
- Slots and campaigns configured in Blueshift
Fetch live content
The SDK provides three methods to fetch live content. Each method requires a slot name and returns content through a callback.
By email
import com.blueshift.Blueshift
import com.blueshift.LiveContentCallback
val slotName = "your_slot_name"
Blueshift.getInstance(context).getLiveContentByEmail(slotName, object : LiveContentCallback {
override fun onReceive(response: String?) {
// Handle the response
}
})
import com.blueshift.Blueshift;
import com.blueshift.LiveContentCallback;
String slotName = "your_slot_name";
Blueshift.getInstance(context).getLiveContentByEmail(slotName, new LiveContentCallback() {
@Override
public void onReceive(String response) {
// Handle the response
}
});
By customer ID
val slotName = "your_slot_name"
Blueshift.getInstance(context).getLiveContentByCustomerId(slotName, object : LiveContentCallback {
override fun onReceive(response: String?) {
// Handle the response
}
})
String slotName = "your_slot_name";
Blueshift.getInstance(context).getLiveContentByCustomerId(slotName, new LiveContentCallback() {
@Override
public void onReceive(String response) {
// Handle the response
}
});
By device ID
val slotName = "your_slot_name"
Blueshift.getInstance(context).getLiveContentByDeviceId(slotName, object : LiveContentCallback {
override fun onReceive(response: String?) {
// Handle the response
}
})
String slotName = "your_slot_name";
Blueshift.getInstance(context).getLiveContentByDeviceId(slotName, new LiveContentCallback() {
@Override
public void onReceive(String response) {
// Handle the response
}
});
Reference documentation
Updated about 5 hours ago