Log In / Log Out with an externalCode
Before using Live Activities, the device must be registered with your backend using an external identifier:
var la = new IndigitallLiveActivity();
// Log In
la.LogIn("yourExternalCode",
onSuccess: device =>
{
Console.WriteLine($"Device registered: {device.DeviceId}");
},
onError: (code, error) =>
{
Console.WriteLine($"Login error [{code}]: {error}");
}
);
// Log Out
la.LogOut(
onSuccess: device =>
{
Console.WriteLine($"Device logged out: {device.DeviceId}");
},
onError: (code, error) =>
{
Console.WriteLine($"Logout error [{code}]: {error}");
}
);
List Active Live Activities
You can retrieve the list of active Live Activities associated with the device:
la.GetListLiveActivities(
onSuccess: liveActivities =>
{
foreach (var item in liveActivities)
{
Console.WriteLine($"ID: {item.LiveActivityId}, Topic: {item.AndroidTopicId}");
}
},
onError: (code, error) =>
{
Console.WriteLine($"Error [{code}]: {error}");
}
);
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
la.TopicsList(
onSuccess: topics =>
{
Console.WriteLine("Subscribed topics: " + string.Join(", ", topics));
},
onError: (code, error) =>
{
Console.WriteLine($"Error [{code}]: {error}");
}
);
Subscribe to Topics
var topicsToSubscribe = new[] { "order_123", "match_live", "flight_abc" };
la.TopicsSubscribe(topicsToSubscribe,
onSuccess: topics =>
{
Console.WriteLine("Successfully subscribed: " + string.Join(", ", topics));
},
onError: (code, error) =>
{
Console.WriteLine($"Subscribe error [{code}]: {error}");
}
);
Unsubscribe from Topics
var topicsToUnsubscribe = new[] { "order_123" };
la.TopicsUnsubscribe(topicsToUnsubscribe,
onSuccess: topics =>
{
Console.WriteLine("Successfully unsubscribed: " + string.Join(", ", topics));
},
onError: (code, error) =>
{
Console.WriteLine($"Unsubscribe error [{code}]: {error}");
}
);
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.