indigitall SDK for Segments clicking here
Segments / Topics
Our SDK allows you to classify users into different customizable groups. This is very useful for:
- Implement a preferences screen so that the user can choose the topics for which they want to receive notifications.
- Label according to the navigation or actions that the user performs.
- Segment communications according to whether the user has identified or is anonymous.
- Segment based on language, culture, customer category, or based on any other criteria you need.
Remember that you must first define the groups you want to work with in the indigitall console (Tools> Topics).
List groups
Use the topicsList method to get the list of groups that are configured in your indigitall project. The callback of this method receives as a parameter an array of Topics, which contains the information of all the available groups, as well as a flag that indicates whether the user is included in any of them.
// Create an instance of IndigitallInApp
Com.Indigitall.Xamarin.iOS.InApp.IndigitallInApp inApp = new Com.Indigitall.Xamarin.iOS.InApp.IndigitallInApp();
// Call TopicsList method
inApp.topicsList(
onSuccess: (topics) =>
{
// This block is executed when topics are successfully retrieved
Console.WriteLine("Received topics:");
foreach (var topic in topics)
{
// Example: print topic information
Console.WriteLine($"- {topic.code}: {topic.name}");
}
},
onFail: (errorCode, errorMessage) =>
{
// This block is executed when an error occurs
Console.WriteLine($"Error {errorCode}: {errorMessage}");
}
);
List groups from console
This method can be customized with the following options:
- IInAppConfiguration (InAppConfiguration): Configuration object.
- appKey (string, required): Application key.
- urlInAppApi (string, optional): Custom InApp API URL. Only required if you work with a custom cloud environment.
- limit: Defines the number of topics that will be returned on each page. The minimum allowed value is 20.
- page: number of the page
When calling the method, you will receive the topics in a paginated format. This means you can check the current page, view the available topics, and continue loading additional pages until there are no more results.
In case of error, the method provides an error callback so you can handle the issue appropriately.
Com.Indigitall.Xamarin.iOS.InApp.IndigitallInApp inApp = new Com.Indigitall.Xamarin.iOS.InApp.IndigitallInApp();
// Create the configuration
var config = new Com.Indigitall.Xamarin.Models.IInAppConfiguration
{
appKey = "YOUR_APP_KEY", // Required: your application key
urlInAppApi = "YOUR_CUSTOM_DOMAIN" // Optional: only if you use a custom API domain
};
// Define pagination parameters
int? page = 0; // Starting page (nullable)
int? limit = 20; // Minimum value is 20 (nullable)
// Call TopicsListFromConsole method
inApp.topicsListFromConsole(
config,
page,
limit,
onSuccess: (topics) =>
{
// This block is executed when topics are successfully retrieved
Console.WriteLine("Topics from console:");
foreach (var topic in topics)
{
Console.WriteLine($"- {topic.Code}: {topic.Name}");
}
},
onFail: (errorCode, errorMessage) =>
{
// This block is executed when an error occurs
Console.WriteLine($"Error {errorCode}: {errorMessage}");
}
);
When the request is successful, the onSuccess callback provides an INInAppPageTopic object.
- Fields
- topics (ArrayList?): List of topics included in the current page.
- currentPage (Int): Current page index. Starts at 0.
Manage subscription
To manage the device subscription to one or more groups, there are two methods: topicsSubscribe and topicsUnsubscribe.
Optionally, both receive a TopicsCallback object as the third parameter, which will return the list of all Topic in the project.
// Create an instance of IndigitallInApp
Com.Indigitall.Xamarin.iOS.InApp.IndigitallInApp inApp = new Com.Indigitall.Xamarin.iOS.InApp.IndigitallInApp();
// List of topic codes to subscribe
string[] topicCodes = { "sports", "news", "offers" };
// Call TopicsSubscribe method
inApp.topicsSubscribe(
topicCodes,
onSuccess: (subscribedTopics) =>
{
// This block is executed when topics are successfully subscribed
Console.WriteLine("Successfully subscribed to topics:");
foreach (var topic in subscribedTopics)
{
Console.WriteLine($"- {topic.code}: {topic.name}");
}
},
onFail: (errorCode, errorMessage) =>
{
// This block is executed when an error occurs
Console.WriteLine($"Error {errorCode}: {errorMessage}");
}
);
// Call TopicsUnsubscribe method
inApp.topicsUnsubscribe(
topicCodes,
onSuccess: (remainingTopics) =>
{
// This block is executed when topics are successfully unsubscribed
Console.WriteLine("Successfully unsubscribed. Remaining topics:");
foreach (var topic in remainingTopics)
{
Console.WriteLine($"- {topic.code}: {topic.name}");
}
},
onFail: (errorCode, errorMessage) =>
{
// This block is executed when an error occurs
Console.WriteLine($"Error {errorCode}: {errorMessage}");
}
);