Profile API reference

Update user attributes

Android
iOS
Android

updateUserAttribute

Sets the user profile attributes key and value and allows you to create or update a user profile attribute.

Remember the following information:

  • If the attribute does not exist, it will be created.

  • If the attribute exists, the value will be updated.

  • A null attribute value removes the attribute.

Syntax

public static void updateUserAttribute(String attributeName,
Object attributeValue)

Example

You want to update username of a user obtained in the log in page :

UserProfile.updateUserAttribute("username", "Will Smith");

updateUserAttributes

Sets the user profile attributes key and value.

Allows you to create/update a batch of user profile attributes:

  • String, Integer, Boolean, Double, Array, Map are valid type of user profile attributes.

  • Custom objects cannot be saved as a UserProfile attribute.

  • If the attribute does not exist, it is created.

  • If the attribute already exists, the value is updated.

  • A null attribute value will remove the attribute.

Syntax

public static void updateUserAttributes(Map<String, Object> attributeMap)

Example

You want to update username, usertype of a user obtained in the log in page :

HashMap<String, Object> profileMap = new HashMap<>();
profileMap.put("username","Will Smith");
profileMap.put("usertype","Actor");
UserProfile.updateUserAttributes(profileMap);
iOS

updateUserAttribute

Sets the user profile attributes key and value and allows you to create or update a user profile attribute.

Remember the following information:

  • If the attribute does not exist, it will be created.

  • If the attribute already exists, then the value will be updated.

  • A null attribute value will remove the attribute.

Syntax

+ (void) updateUserAttribute: (nonnull NSString*) attributeName withValue: (nullable NSString*) attributeValue;

Examples

You want to update username of a user obtained in the log in page:

Objective-C

[ACPUserProfile updateUserAttribute:@"username" withValue:@"Will Smith"];

Swift

ACPUserProfile.updateUserAttribute("username", withValue: "Will Smith");

updateUserAttributes

Sets the user profile attributes key and value.

Allows to create/update a batch of user profile attributes:

  • String, Integer, Boolean, Double, Array, Map are valid type of user profile attributes.

  • We do not allow custom objects to be saved as a UserProfile attribute.

  • If the attribute already exists, then the value will be updated.

  • If the attribute does not exist, it will be created.

A null attribute value will remove the attribute.

Syntax

+ (void) updateUserAttributes: (nonnull NSDictionary*) attributeMap

Examples

You want to update username, usertype of a user obtained in the log in page :

Objective C

NSMutableDictionary *profileMap = [NSMutableDictionary dictionary];
[profileMap setObject:@"username" forKey:@"will_smith"];
[profileMap setObject:@"usertype" forKey:@"Actor"];
[ACPUserProfile updateUserAttributes:profileMap];

Swift

var profileMap = [AnyHashable: Any]()
profileMap["username"] = "will_smith"
profileMap["usertype"] = "Actor"
ACPUserProfile.updateUserAttributes(profileMap)

Remove user attributes

Android
iOS
Android

removeUserAttribute

Removes the user profile attribute for the given key.

Syntax

public static void removeUserAttribute(String attributeName)

Example

A retail application wants to remove the itemsAddedToCart user data after the product is purchased.

UserProfile.removeUserAttribute("itemsAddedToCart");

removeUserAttributes

Removes the user profile attributes for the given keys.

Syntax

public static void removeUserAttributes(List<String> attributeNames)

Example

You want to remove username, usertype user data when session timeout occurs.

UserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
iOS

removeUserAttribute

Removes the user profile attribute for the given key.

Syntax

+ (void) removeUserAttribute: (nonnull NSString*) key

Examples

A retail application wants to remove the itemsAddedToCart user data after the product is purchased.

Objective C

[ACPUserProfile removeUserAttribute:@"itemsAddedToCart"];

Swift

ACPUserProfile.removeUserAttribute("itemsAddedToCart");

removeUserAttributes

Removes the user profile attributes for the given keys.

Syntax

+ (void) removeUserAttributes: (nonnull NSArray <NSString*>*) attributeNames

Examples

You want to remove username, usertype user data when session timeout occurs.

Objective C

[ACPUserProfile removeUserAttributes:@[@"username", @"usertype"]]

Swift

ACPUserProfile.removeUserAttributes(["username","usertype"]);

Get user attributes

Android
iOS
Android

getUserAttributes

Gets the user profile attributes with the given keys.

Syntax

public static void getUserAttributes(List<String> keys, AdobeCallback<Map<String, Object>> callback)
  • callback is invoked after the customer attributes are available.

Example

A retail application wants to get the itemsAddedToCart user data when processing checkout.

When AdobeCallbackWithError is provided, if the operation times out (5s) or an unexpected error occurs, the fail method is called with the appropriate AdobeError.

UserProfile.getUserAttributes(Arrays.asList("itemsAddedToCart"), new AdobeCallbackWithError<Map<String, Object>>() {
@Override
public void fail(AdobeError adobeError) {
// your customized code
}
@Override
public void call(Map<String, Object> stringObjectMap) {
// your customized code
}
});
iOS

getUserAttributes

Gets the user profile attributes with the given keys.

Syntax

+ (void) getUserAttributes: (nullable NSArray <NSString*>*) attributNames withCompletionHandler: (nonnull void (^) (NSDictionary* __nullable userAttributes, NSError* _Nullable error)) completionHandler
  • completionHandler is invoked after the customer attributes are available, or error if an unexpected error occurs or the request times out. The default timeout is 5s.

Examples

A retail application wants to get the itemsAddedToCart user data when processing checkout.

Objective C

[ACPUserProfile getUserAttributes:attributes withCompletionHandler:^(NSDictionary* dict, NSError* error){
// your customized code
}];

Swift

ACPUserProfile.getUserAttributes(["itemsAddedToCart"], withCompletionHandler: {(dict: [AnyHashable: Any]?, error: Error?) -> Void in
// your customized code
})