Advanced Settings

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 MIndigitallInApp
var inApp = new MIndigitallInApp();

// 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:

  • INDMInAppConfiguration (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.

var inApp = new MIndigitallInApp();

// Create the configuration
var config = new INDMInAppConfiguration
{
    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 MIndigitallInApp
var inApp = new MIndigitallInApp();

// 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}");
    }
);