Advance 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.

import {InApp} from 'indigitall-react-native-plugin';

// Call the method
InApp.inAppTopicsList(
  (topics) => {
    // This block is executed when topics are successfully retrieved
    console.log("All topics:");
    topics.forEach((topic) => {
      console.log(`- ${topic.code}: ${topic.name}`);
    });
  },
  (error) => {
    // This block is executed when an error occurs
    console.error(`Error ${error.code}: ${error.message}`);
  }
);

List groups from console

This method can be customized with the following options:

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

import {InApp} from 'indigitall-react-native-plugin';

// Define the parameters
const params: InAppTopicListParams = {
  appKey: "YOUR_APP_KEY",                 // Required: your application key
  domainInApp: "YOUR_CUSTOM_DOMAIN", // Optional: only if you use a custom API domain
  limit: 20,   // Minimum value is 20
  page: 0      // Starting page
};

// Call the method
InApp.inAppTopicsListFromConsole(
  params,
  (topics) => {
    // This block is executed when topics are successfully retrieved
    console.log("Topics from console:");
    topics.forEach((topic) => {
      console.log(`- ${topic.code}: ${topic.name}`);
    });
  },
  (error) => {
    // This block is executed when an error occurs
    console.error(`Error ${error.code}: ${error.message}`);
  }
);

When the request is successful, the onSuccess callback provides an INInAppPageTopic object.

  • Fields
    • topics (ArrayList?): List of topics included in the current page.

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.

import {InApp} from 'indigitall-react-native-plugin';

// List of topics to subscribe
const topicsToSubscribe: TopicStringParams[] = [
  { code: "sports" },
  { code: "news" },
  { code: "offers" }
];

// Call the method
InApp.inAppTopicsSubscribe(
  topicsToSubscribe,
  (topics) => {
    // This block is executed when topics are successfully subscribed
    console.log("Successfully subscribed to topics:");
    topics.forEach((topic) => {
      console.log(`- ${topic.code}: ${topic.name}`);
    });
  },
  (error) => {
    // This block is executed when an error occurs
    console.error(`Error ${error.code}: ${error.message}`);
  }
);


// Call the method
InApp.inAppTopicsUnsubscribe(
  topicsToUnsubscribe,
  (topics) => {
    // This block is executed when topics are successfully unsubscribed
    console.log("Successfully unsubscribed from topics. Remaining subscriptions:");
    topics.forEach((topic) => {
      console.log(`- ${topic.code}: ${topic.name}`);
    });
  },
  (error) => {
    // This block is executed when an error occurs
    console.error(`Error ${error.code}: ${error.message}`);
  }
);