For the complete documentation index, see llms.txt. This page is also available as Markdown.

Topic preferences

The Batch iOS SDK allows you to:

  • Add or remove topic preferences from a user profile (the profile is created automatically if it doesn’t already exist).

  • Partially update topic preferences within a user profile.

Requires SDK 3.3+

Here’s how to update topic preferences:

BatchProfile.editor { editor in
    try? editor.setTopicPreferences(["technology", "finance"]) // Null to erase
    // Alternatively, partially update them with:
    try? editor.addToTopicPreferences(["investing"])
    try? editor.removeFromTopicPreferences(["travel"])
    // If you prefer to use BatchProfile.editor() with local variable instead of using a closure,
    // remember to use editor.save() afterwards so that the changes are taken into account.
}
// This requires to have a custom user ID registered by calling the `identify` method beforehand.
[BatchProfile editWithBlock:^(BatchProfileEditor * _Nonnull editor) {
     NSError *error = nil;
     [editor setTopicPreferences:@[@"technology", @"finance"] error:&error];
     // Alternatively, partially update them with:
     [editor addToTopicPreferences:@[@"investing"] error:&error];
     [editor removeFromTopicPreferences:@[@"travel"] error:&error];
     // If you prefer to use [BatchProfile editor] instead of `editWithBlock`,
     // remember to use [editor save] afterwards so that the changes are taken into account.
}];

Note: Topics must be a valid List of String not longer than 25 items. String should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 300 characters.

Topics are deduplicated and follows a last-wins rule: if a value already exists in the array, it is moved to the end. Size limits are enforced after deduplication.

Last updated