BatchUser

@interface BatchUser

Batch’s User Module

  • Get the unique installation ID, generated by Batch.

    Declaration

    Objective-C

    + (id)installationID;

    Return Value

    Batch-generated installation ID. Might be nil if Batch isn’t started.

  • Get the user data editor Do not forget to call save once you’re done changing the attributes

    You can call this method from any thread.

    Declaration

    Objective-C

    + (id)editor;

    Return Value

    A BatchUserDataEditor instance

  • Declaration

    Objective-C

    + (id)language;

    Return Value

    The custom language set with @p BatchUserDataEditor, or nil if none was set.

  • Declaration

    Objective-C

    + (id)region;

    Return Value

    The region set with @p BatchUserDataEditor, or nil if none was set.

  • Declaration

    Objective-C

    + (id)identifier;

    Return Value

    The custom identifier set with @p BatchUserDataEditor, or nil if none was set.

  • Read the saved attributes. Reading is asynchronous so as not to interfere with saving operations.

    Declaration

    Objective-C

    + (void)fetchAttributes:(void (^_Nonnull)(int))completionHandler;

    Parameters

    completionHandler

    Completion block that contains a dictionary of attributes. The keys are the ones used when setting the attributes, the values are of type BatchUserAttribute. See BatchUserAttribute for more information.

  • Read the saved tag collections. Reading is asynchronous so as not to interfere with saving operations.

    Note

    Tags are saved in lowercase.

    Declaration

    Objective-C

    + (void)fetchTagCollections:(void (^_Nonnull)(int))completionHandler;

    Parameters

    completionHandler

    Completion block that contains a dictionary of sets of tags. The keys are the ones used when setting the tags collections.

  • Track an event You can call this method from any thread. Batch must be started at some point, or events won’t be sent to the server.

    Declaration

    Objective-C

    + (void)trackEvent:(id)event;

    Parameters

    event

    The event name. It should be made of letters, numbers or underscores ([a-z0-9_]) and can’t be longer than 30 characters.

  • Track an event You can call this method from any thread. Batch must be started at some point, or events won’t be sent to the server.

    Declaration

    Objective-C

    + (void)trackEvent:(id)event withLabel:(id)label;

    Parameters

    event

    The event name. It should be made of letters, numbers or underscores ([a-z0-9_]) and can’t be longer than 30 characters.

    label

    The event label (optional). Must be a string.

  • Deprecated

    Please migrate to [BatchUser trackEvent:withLabel:associatedData:]. Data sent using this method might be truncated if it can’t be converted to a BatchEventData instance.

    Track an event You can call this method from any thread. Batch must be started at some point, or events won’t be sent to the server.

    @deprecated See [BatchUser trackEvent:withLabel:associatedData:]. Data sent using this method might be truncated if it can’t be converted to a BatchEventData instance.

    Declaration

    Objective-C

    + (void)trackEvent:(id)event withLabel:(id)label data:(id)data;

    Parameters

    event

    The event name. It should be made of letters, numbers or underscores ([a-z0-9_]) and can’t be longer than 30 characters.

    label

    The event label (optional). Must be a string.

    data

    The event data (optional). Must a serializable JSON Foundation dictionary (meaning that it must pass +[NSJSONSerialization isValidJSONObject]‘s check). See NSJSONSerialization documentation for supported types, with the only difference that the top level object MUST BE a NSDictionary and not a NSArray.

  • Track an event You can call this method from any thread. Batch must be started at some point, or events won’t be sent to the server.

    Declaration

    Objective-C

    + (void)trackEvent:(id)event
             withLabel:(id)label
        associatedData:(nullable BatchEventData *)data;

    Parameters

    event

    The event name. It should be made of letters, numbers or underscores ([a-z0-9_]) and can’t be longer than 30 characters.

    label

    The event label (optional). Must be a string.

    data

    The event data (optional).

  • Track a transaction You can call this method from any thread. Batch must be started at some point, or events won’t be sent to the server.

    Declaration

    Objective-C

    + (void)trackTransactionWithAmount:(double)amount;

    Parameters

    amount

    Transaction’s amount.

  • Track a transaction You can call this method from any thread. Batch must be started at some point, or events won’t be sent to the server.

    Declaration

    Objective-C

    + (void)trackTransactionWithAmount:(double)amount data:(id)data;

    Parameters

    amount

    Transaction’s amount.

    data

    The transaction data (optional). Must a serializable JSON Foundation dictionary (meaning that it must pass +[NSJSONSerialization isValidJSONObject]‘s check). See NSJSONSerialization documentation for supported types, with the only difference that the top level object MUST BE a NSDictionary and not a NSArray.

  • Track a geolocation update You can call this method from any thread. Batch must be started at some point, or location updates won’t be sent to the server. You’ll usually call this method in your CLLocationManagerDelegate implementation

    Declaration

    Objective-C

    + (void)trackLocation:(id)location;

    Parameters

    location

    The user’s location in the form of a CLLocation object, ideally the one provided by the system to your delegate.

  • Print the currently known attributes and tags for a user to the logs (stderr/syslog).

    Declaration

    Objective-C

    + (void)printDebugInformation;