Attributes
In addition of setting a custom user ID, an email address or overriding the language/region, you can assign attributes to your users, allowing you to improve your orchestrations targeting.

Important:
User IDs must be managed using our custom user ID implementation.
Email address must be managed using our email subscription implementation.
Region/language data must be managed using our custom region/language implementation.
Never use an existing tagging plan.
Newly tracked attributes are hidden by default. You will need to manually display them from the dashboard settings.
Managing attributes
Before we get started on how to implement attributes, here are some rules you should know.
Naming
Attribute names are strings. They should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters (e.g. has_premium).
Values
Values must be any of the following types, or their native Swift equivalent:
NSString Must not be longer than 300 characters and cannot be empty. For better results, you should make them upper/lowercase and trim the whitespaces.
NSNumber
Anything bigger than a long long or a double will be rejected.
Unsigned values will be rejected.
Booleans are supported, but should be initialized with [NSNumber numberWithBool:<your value>] or @YES/@NO.
NSDate Since timezones are not supported, this will typically represent UTC dates.
Using any unsupported type as a value (NSNull, NSObject, NSArray, NSDictionary for example) will NOT work. Be careful, as it may cause
[editor save]to fail.
NSURL
Must not be longer than 2048 characters and must follow the format scheme://[authority][path][?query][#fragment].
NSArray<NSString> Must not be longer than 25 items, only values of type NSString and must respect the string attribute limitations.
Setting an attribute
The custom attribute API works using an editor. You need to get an instance of the editor, enqueue your changes and then call save.
Changes will NOT be sent until you call this method, please make sure you call it!
There is one setAttribute/set(attribute:forKey:) method per attribute type. Use Xcode's autocompletion or see BatchProfileEditor.h for all available variants. If you're using Swift, the appropriate method will automatically be used according to the value's type.
Those methods throw an error if key/value failed validation according to the rules expressed higher up in this documentation. Note that no error does not mean the value has already been sent to the server.
You might be tempted to write helpers or loops that open and save many transactions in a row, with each transaction only doing one operation. Doing so prevents Batch from optimizing disk usage and network roundtrips, which impact your user's data plan and battery life. Please try to batch as many operations as you can in a single transaction.
Please test your implementation using our debug tool and profile view before releasing your app on the store. Make sure you're unwrapping your optionals!
Removing attributes
Use removeAttributeForKey to remove an attribute of any type.
Reading attributes and tag collections
Since Batch SDK v2, updating the user's data also update the profile's data to be accessible from your project scope. This mean the following APIs only read local data related to your installation and NOT to your profile.
You may also have noticed that APIs to set Tags or Tag Collections have been removed and replaced by array attributes. These methods are backward-compatible and array attributes are converted into tag collections to not break your implementation.
Reading attributes
Reading tag collections
Clearing installation data
Clearing the installation data will delete all tags and attributes set on an installation and their local cache returned by fetchAttributes and fetchTagCollections. It can be done as following:
Last updated

