Class BatchProfileAttributeEditor

java.lang.Object
com.batch.android.BatchProfileAttributeEditor

public class BatchProfileAttributeEditor extends Object
Batch Profile Attribute Editor

Profiles centralize data and events from multiple sources (Apps, Websites, APIs) in a single place based on the Custom ID. They also store a profile's email address and email subscriptions.

The Batch Profile Attribute Editor allows you to update profiles to:

Set attributes Set email subscription status and email address Set a language & region

  • Field Details

  • Method Details

    • setLanguage

      public BatchProfileAttributeEditor setLanguage(String language)
      Set the language of this profile.
      Overrides the detected installation language.
      Parameters:
      language - lowercase, ISO 639 formatted string. null to reset.
      Returns:
      This object instance, for method chaining
    • setRegion

      public BatchProfileAttributeEditor setRegion(String region)
      Set the region of this profile.
      Overrides the detected installation region.
      Parameters:
      region - uppercase, ISO 3166 formatted string. null to reset.
      Returns:
      This object instance, for method chaining
    • setEmailAddress

      public BatchProfileAttributeEditor setEmailAddress(String email)
      Set the profile email address.

      Note: This method requires to already have a registered identifier for the user or to call Batch.Profile#identify(String) method before this one.

      Parameters:
      email - Email address string
      Returns:
      This object instance, for method chaining.
    • setEmailMarketingSubscription

      public BatchProfileAttributeEditor setEmailMarketingSubscription(BatchEmailSubscriptionState state)
      Set the profile email marketing subscription state.

      Note that profile's subscription status is automatically set to unsubscribed when they click an unsubscribe link.

      Parameters:
      state - State of the subscription
      Returns:
      This object instance, for method chaining.
    • setPhoneNumber

      public BatchProfileAttributeEditor setPhoneNumber(String phoneNumber)
      Set the profile phone number.

      Note: This method requires to already have a registered identifier for the user or to call Batch.Profile#identify(String) method before this one.

      Example:

       Batch.Profile.identify("my_custom_user_id")
       Batch.Profile.editor().setPhoneNumber("+33123456789").save()
       
      Parameters:
      phoneNumber - A valid E.164 formatted string. Must start with a `+` and not be no longer than 15 digits without special characters (eg: "+33123456789"). Null to reset.
      Returns:
      This object instance, for method chaining.
      See Also:
    • setSMSMarketingSubscription

      public BatchProfileAttributeEditor setSMSMarketingSubscription(BatchSMSSubscriptionState state)
      Set the profile SMS marketing subscription state.

      Note that profile's subscription status is automatically set to unsubscribed when they send a STOP message.

      Parameters:
      state - State of the subscription
      Returns:
      This object instance, for method chaining.
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, long value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value.
      Returns:
      This object instance, for method chaining
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, double value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value.
      Returns:
      This object instance, for method chaining
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, boolean value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value.
      Returns:
      This object instance, for method chaining
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, Date value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value, can't be null. Note that since timezones are not supported, this will typically represent UTC dates.
      Returns:
      This object instance, for method chaining
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, String value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value, can't be null or empty. Must be a string not longer than 64 characters. For better results, you should make them upper/lowercase and trim the whitespaces.
      Returns:
      This object instance, for method chaining
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, URI value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value, can't be null or empty. Must be a valid URI not longer than 2048 character.
      Returns:
      This object instance, for method chaining
    • setAttribute

      public BatchProfileAttributeEditor setAttribute(String key, List<String> value)
      Set a custom profile attribute for a key.
      Parameters:
      key - Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Attribute value, can't be null or empty. Must be a valid List not longer than X items.
      Returns:
      This object instance, for method chaining
    • removeAttribute

      public BatchProfileAttributeEditor removeAttribute(String key)
      Removes a custom attribute.
      Does nothing if it was not set.
      Parameters:
      key - Attribute key
      Returns:
      This object instance, for method chaining
    • addToArray

      public BatchProfileAttributeEditor addToArray(String key, String value)
      Add a string value in the specified array attribute. If empty, the collection will automatically be created.
      Parameters:
      key - The array attribute to add the value to. Cannot be null. Must be a string of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - The value to add. Cannot be null or empty. Must be a string no longer than 64 characters.
      Returns:
      This object instance, for method chaining
    • addToArray

      public BatchProfileAttributeEditor addToArray(String key, List<String> values)
      Add a list of strings in the specified array attribute. If empty, the collection will automatically be created.
      Parameters:
      key - The array attribute to add the value to. Cannot be null. Must be a string of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      values - The strings to add. Cannot be null or empty. Must be strings no longer than 64 characters and max 25 items
      Returns:
      This object instance, for method chaining
    • removeFromArray

      public BatchProfileAttributeEditor removeFromArray(String key, String value)
      Removes a string from an array attribute. Does nothing if the tag does not exist.
      Parameters:
      key - Array attribute name
      value - The value to remove
      Returns:
      This object instance, for method chaining
    • removeFromArray

      public BatchProfileAttributeEditor removeFromArray(String key, List<String> values)
      Removes a list of strings from an array attribute. Does nothing if the tag does not exist.
      Parameters:
      key - Array attribute name
      values - The values to remove
      Returns:
      This object instance, for method chaining
    • save

      public void save()
      Save all of the pending changes made in that editor. Note if Batch is not started, your changes will be enqueue until it start. Once you called "save", you need to get a new editor in order to make further changes.

      This action cannot be undone.