Log In / Log Out with an externalCode
Before using Live Activities, the device must be registered with your backend using an external identifier:
// Log In
IndigitallLA.login(context, "yourExternalCode", object : LADeviceCallback(context) {
override fun onSuccess(device: LADevice) {
Log.d("LiveActivities", "Device registered")
}
override fun onError(errorId: Int?, errorMessage: String?, descriptionMessage: String?) {
Log.e("LiveActivities", "Login error: $errorMessage - $descriptionMessage")
}
})
// Log Out
IndigitallLA.logOut(context, object : LADeviceCallback(context) {
override fun onSuccess(device: LADevice) {
Log.d("LiveActivities", "Device logged out")
}
override fun onError(errorId: Int?, errorMessage: String?, descriptionMessage: String?) {
Log.e("LiveActivities", "Logout error: $errorMessage - $descriptionMessage")
}
})
IndigitallLA.login(context, "yourExternalCode", new LADeviceCallback(context) {
@Override
public void onSuccess(LADevice device) {
Log.d("LiveActivities", "Device registered");
}
@Override
public void onError(Integer errorId, String errorMessage, String descriptionMessage) {
Log.e("LiveActivities", "Login error: " + errorMessage + " - " + descriptionMessage);
}
});
IndigitallLA.logOut(context, new LADeviceCallback(context) {
@Override
public void onSuccess(LADevice device) {
Log.d("LiveActivities", "Device logged out");
}
@Override
public void onError(Integer errorId, String errorMessage, String descriptionMessage) {
Log.e("LiveActivities", "Logout error: " + errorMessage + " - " + descriptionMessage);
}
});List Active Live Activities
You can retrieve the list of active Live Activities associated with the device:
IndigitallLA.getListLiveActivities(context, object : LACallback() {
override fun onSuccess(liveActivities: ArrayList<LiveActivity>) {
liveActivities.forEach {
Log.d("LiveActivity", "ID: ${it.liveActivityId}, Topic: ${it.androidTopicId}")
}
}
override fun onError(errorId: Int?, errorMessage: String?, descriptionMessage: String?) {
Log.e("LiveActivity", "Error: $errorMessage - $descriptionMessage")
}
})
IndigitallLA.getListLiveActivities(context, new LACallback() {
@Override
public void onSuccess(ArrayList<LiveActivity> liveActivities) {
for (LiveActivity activity : liveActivities) {
Log.d("LiveActivity", "ID: " + activity.getLiveActivityId()
+ ", Topic: " + activity.getAndroidTopicId());
}
}
@Override
public void onError(Integer errorId, String errorMessage, String descriptionMessage) {
Log.e("LiveActivity", "Error: " + errorMessage + " - " + descriptionMessage);
}
});Manage Topics (Subscribe / Unsubscribe / List)
Each Live Activity is identified by a unique topic. Use these methods to control which ones the device is subscribed to.
List topics
IndigitallLA.topicList(context, object : LATopicCallback(context) {
override fun onSuccess(topics: ArrayList<String>?) {
Log.d("Topics", "Subscribed topics: $topics")
}
override fun onError(errorId: Int?, errorMessage: String?, descriptionMessage: String?) {
Log.e("Topics", "Error: $errorMessage - $descriptionMessage")
}
})
IndigitallLA.topicList(context, new LATopicCallback(context) {
@Override
public void onSuccess(ArrayList<String> topics) {
Log.d("Topics", "Subscribed topics: " + topics);
}
@Override
public void onError(Integer errorId, String errorMessage, String descriptionMessage) {
Log.e("Topics", "Error: " + errorMessage + " - " + descriptionMessage);
}
});Subscribe to Topics
val topicsToSubscribe = arrayListOf("order_123", "match_live", "flight_abc")
IndigitallLA.subscribeToTopic(context, topicsToSubscribe, object : LATopicCallback(context) {
override fun onSuccess(topics: ArrayList<String>?) {
Log.d("Topics", "Successfully subscribed: $topics")
}
override fun onError(errorId: Int?, errorMessage: String?, descriptionMessage: String?) {
Log.e("Topics", "Subscribe error: $errorMessage - $descriptionMessage")
}
})
ArrayList<String> topicsToSubscribe = new ArrayList<>(Arrays.asList(
"order_123", "match_live", "flight_abc"));
IndigitallLA.subscribeToTopic(context, topicsToSubscribe, new LATopicCallback(context) {
@Override
public void onSuccess(ArrayList<String> topics) {
Log.d("Topics", "Successfully subscribed: " + topics);
}
@Override
public void onError(Integer errorId, String errorMessage, String descriptionMessage) {
Log.e("Topics", "Subscribe error: " + errorMessage + " - " + descriptionMessage);
}
});Unsubscribe from Topics
val topicsToUnsubscribe = arrayListOf("order_123")
IndigitallLA.unsubscribeToTopic(context, topicsToUnsubscribe, object : LATopicCallback(context) {
override fun onSuccess(topics: ArrayList<String>?) {
Log.d("Topics", "Successfully unsubscribed: $topics")
}
override fun onError(errorId: Int?, errorMessage: String?, descriptionMessage: String?) {
Log.e("Topics", "Unsubscribe error: $errorMessage - $descriptionMessage")
}
})
ArrayList<String> topicsToUnsubscribe = new ArrayList<>(Collections.singletonList("order_123"));
IndigitallLA.unsubscribeToTopic(context, topicsToUnsubscribe, new LATopicCallback(context) {
@Override
public void onSuccess(ArrayList<String> topics) {
Log.d("Topics", "Successfully unsubscribed: " + topics);
}
@Override
public void onError(Integer errorId, String errorMessage, String descriptionMessage) {
Log.e("Topics", "Unsubscribe error: " + errorMessage + " - " + descriptionMessage);
}
});Push Notification Behavior
Once subscribed, the server can send:
- Visible push: Appears as a fixed notification (e.g., "Your delivery is 5 minutes away").
- Silent push: Triggers background processing or data updates without interrupting the user.
You have full control of:
- Notification layout
- Priority and sound
- Persistence (ongoing)
- Auto-dismiss logic
Notes
- Topics allow a 1:1 mapping with live events.
- This approach is compatible with all modern Android versions.
- Make sure to handle push reception in your FirebaseMessagingService.
Example of FirebaseMessagingService
class MyFirebaseService : com.indigitall.android.push.services.FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
try {
val json = JSONObject(remoteMessage.data)
val liveActivityPush = LAPush(json)
if (liveActivityPush.pushType == PushType.LIVE_ACTIVITY) {
when (liveActivityPush.liveActivityEventType) {
LAEventType.START -> {
// Start the Live Activity
}
LAEventType.UPDATE -> {
// Update the Live Activity
}
LAEventType.END -> {
// End the Live Activity
}
null -> Unit
}
} else {
// Display a standard Indigitall notification.
super.onMessageReceived(remoteMessage)
}
} catch (exception: Exception) {
Log.e("LiveActivities", "Unable to process message", exception)
super.onMessageReceived(remoteMessage)
}
}
override fun onNewToken(token: String) {
super.onNewToken(token)
}
}public class MyFirebaseService extends com.indigitall.android.push.services.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
try {
JSONObject json = new JSONObject(remoteMessage.getData());
LAPush liveActivityPush = new LAPush(json);
if (liveActivityPush.getPushType() == PushType.LIVE_ACTIVITY) {
LAEventType eventType = liveActivityPush.getLiveActivityEventType();
if (eventType == LAEventType.START) {
// Start the Live Activity
} else if (eventType == LAEventType.UPDATE) {
// Update the Live Activity
} else if (eventType == LAEventType.END) {
// End the Live Activity
}
} else {
// Display a standard Indigitall notification.
super.onMessageReceived(remoteMessage);
}
} catch (Exception exception) {
Log.e("LiveActivities", "Unable to process message", exception);
super.onMessageReceived(remoteMessage);
}
}
@Override
public void onNewToken(String token) {
super.onNewToken(token);
}
}