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.
InAppIndigitall.topicsListWith { topics in
//get codes
}, onError: { (error) in
//print error
}
[InAppIndigitall topicsListWithOnSuccess:^(NSArray<INInAppTopic *> * _Nonnull topics) {
//get topics
} onError:^(INError * _Nonnull error) {
//print error
}];
List groups from console
This method can be customized with the following options:
- inAppConfig (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.
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.
val inAppConfig = InAppConfiguration.Builder(appKey)
.setUrlInAppApi(inAppApi) // Optional: only if you use a custom cloud
.build()
Indigitall.inAppTopicsListFromConsole(
context,
inAppConfig,
20, // Minimum value is 20
object : InAppTopicListFromConsoleCallback(context) {
override fun onSuccess(inAppPageTopic: InAppPageTopic) {
// Access current page topics
println("Topics page ${inAppPageTopic.currentPage}: ${inAppPageTopic.topics}")
// Check if more pages are available
if (inAppPageTopic.hasNextPage()) {
inAppPageTopic.loadNextPage(this) // Loads the next page
} else {
println("No more InApp topics available")
}
}
override fun onError(error: InAppErrorModel) {
// Handle error
println("Error retrieving topics: $error")
}
}
)
When the request is successful, the onSuccess callback provides an InAppPageTopic object.
- Fields
- topics (ArrayList?): List of topics included in the current page.
- currentPage (Int): Current page index. Starts at 0.
- total (Int): Total number of topics available across all pages.
- pageSize (Int): Maximum number of topics per page, obtained from configuration.
- totalPages (Double): Total number of pages available, calculated as total / pageSize.
- Methods
- hasNextPage(): Boolean
Returns true if there are additional pages of topics to load. - loadNextPage(callback: InAppTopicListFromConsoleCallback)
Loads the next page of topics. If there are no more pages available, it will call onError with the code INAPP_TOPIC_LIST_NO_MORE_PAGES.
- hasNextPage(): Boolean
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.
InAppIndigitall.topicsSubscribe(withArrayString: []) { topics in
//get codes
}
InAppIndigitall.topicsSubscribe(withTopicArray: []) { topics in
//get codes
}
InAppIndigitall.topicsUnSubscribe(withArrayString: []) { topics in
//get codes
}
InAppIndigitall.topicsUnSubscribe(withTopicArray: []) { topics in
//get codes
}
[InAppIndigitall topicsSubscribeWithArrayString:@[topics] onSuccess:^(NSArray<NSString *> * _Nonnull topics) {
//get codes
} onError:^(INError * _Nonnull error) {
//print error
}];
[InAppIndigitall topicsUnSubscribeWithArrayString:@[topics] onSuccess:^(NSArray<NSString *> * _Nonnull topics) {
//get codes
} onError:^(INError * _Nonnull error) {
//print error
}];
Profile
You can set the profile variable when displaying an InApp. This allows you to add an additional type of filter — for example, if you want to control the display of the InApp for different users within the same campaign, without needing to create multiple ones with the same schema code.
var config: INInAppConfig!
config = InAppConfig.init()
config.appKey= "YOUR_APP_KEY"
//only Enterprise cases
config.domainInApp = " https://{{cloud}}.device-api.indigitall.com/v2"
config.profile = "YOUR_PROFILE"