{% tabs %} {% tab title="Android" %}
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.
public static void updateUserAttribute(String attributeName,
Object attributeValue)You want to update username of a user obtained in the log in page :
UserProfile.updateUserAttribute("username", "Will Smith");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
UserProfileattribute. - 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.
public static void updateUserAttributes(Map<String, Object> attributeMap)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);{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
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
UserProfileattribute. - 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.
public static func updateUserAttributes(attributeDict: [String: Any])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"];
[AEPMobileUserProfile updateUserAttributes:profileMap];Swift
var profileMap = [AnyHashable: Any]()
profileMap["username"] = "will_smith"
profileMap["usertype"] = "Actor"
UserProfile.updateUserAttributes(attributeDict: profileMap){% endtab %}
{% tab title="iOS (ACP 2.x)" %}
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.
+ (void) updateUserAttribute: (nonnull NSString*) attributeName withValue: (nullable NSString*) attributeValue;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");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
UserProfileattribute. - 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.
+ (void) updateUserAttributes: (nonnull NSDictionary*) attributeMap
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){% endtab %}
{% tab title="Cordova" %}
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.
ACPUserProfile.updateUserAttribute = function(attributeName, attributeValue, success, fail);- attributeName is a string containing the name of the user profile attribute to create or update.
- attributeValue must be a string, number, or array containing the user profile attribute value.
- success is a callback containing a general success message if the updateUserAttribute API executed without any errors.
- fail is a callback containing error information if the updateUserAttribute API was executed with errors.
You want to update username of a user obtained in the log in page :
ACPUserProfile.updateUserAttribute("username", "Will Smith", handleCallback, handleError);Sets the user profile attributes key and value.
Allows you to create/update a batch of user profile attributes:
- String, Number, and Array are valid types of user profile attributes.
- Custom objects cannot be saved as a
UserProfileattribute. - 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.
ACPUserProfile.updateUserAttributes = function(attributes, success, fail);- attributes is a object containing a batch of user profile attributes to create or update.
- success is a callback containing a general success message if the updateUserAttributes API executed without any errors.
- fail is a callback containing error information if the updateUserAttributes API was executed with errors.
You want to update username, usertype of a user obtained in the log in page :
var username = "will_smith";
var usertype = "Actor";
var attributes = {"username":username, "usertype":usertype};
ACPUserProfile.updateUserAttributes(attributes, handleCallback, handleError);{% endtab %}
{% tab title="Flutter" %}
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.
static Future<void> updateUserAttribute(String attributeName, String attributeValue) async- attributeName is a string containing the name of the user profile attribute to create or update.
- attributeValue must be a string, number, or array containing the user profile attribute value.
You want to update username of a user obtained in the log in page :
FlutterACPUserProfile.updateUserAttribute("username", "Will Smith");Sets the user profile attributes key and value.
Allows you to create/update a batch of user profile attributes:
- String, Number, and Array are valid types of user profile attributes.
- Custom objects cannot be saved as a
UserProfileattribute. - 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.
static Future<void> updateUserAttributes(Map<String, Object> attributeMap) async- attributeMap is a object containing a batch of user profile attributes to create or update.
You want to update username, usertype of a user obtained in the log in page :
FlutterACPUserProfile.updateUserAttributes({"username":"will_smith", "usertype":"Actor"});{% endtab %}
{% tab title="Xamarin" %}
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.
Android
public unsafe static void UpdateUserAttribute (string attributeName, Java.Lang.Object attributeValue);- attributeName is a string containing the name of the user profile attribute to create or update.
- attributeValue must be a String, Integer, Boolean, Double, Array, or Map containing the user profile attribute value. Custom objects cannot be saved as a
UserProfileattribute.
iOS
public static void UpdateUserAttribute (string attributeName, string attributeValue);- attributeName is a string containing the name of the user profile attribute to create or update.
- attributeValue is a string containing the user profile attribute value.
You want to update username of a user obtained in the log in page :
ACPUserProfile.updateUserAttribute("username", "Will Smith");Sets the user profile attributes key and value.
Allows you to create/update a batch of user profile attributes:
- String, Integer, Boolean, Double, Array, or Map are valid types of user profile attributes.
- Custom objects cannot be saved as a
UserProfileattribute. - 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.
Android
public unsafe static void UpdateUserAttributes (IDictionary<string, Java.Lang.Object> attributeMap);- attributeMap is a object containing a batch of user profile attributes to create or update.
iOS
public static void UpdateUserAttributes (NSDictionary attributeMap);- attributeMap is a object containing a batch of user profile attributes to create or update.
You want to update username, usertype of a user obtained in the log in page :
Android
var attributes = new Dictionary<string, Java.Lang.Object>();
attributes.Add("username", "will_smith");
attributes.Add("usertype", "Actor");
ACPUserProfile.UpdateUserAttributes(attributes);iOS
var attributes = new NSMutableDictionary<NSString, NSString>
{
["username"] = new NSString("will_smith"),
["usertype"] = new NSString("Actor")
};
ACPUserProfile.updateUserAttributes(attributes);{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Android" %}
Removes the user profile attribute for the given key.
public static void removeUserAttribute(String attributeName)A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
UserProfile.removeUserAttribute("itemsAddedToCart");Removes the user profile attributes for the given keys.
public static void removeUserAttributes(List<String> attributeNames)You want to remove username, usertype user data when session timeout occurs.
UserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Removes the user profile attributes for the given keys.
public static void removeUserAttributes(List<String> attributeNames)You want to remove username, usertype user data when session timeout occurs.
UserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Removes the user profile attribute for the given key.
+ (void) removeUserAttribute: (nonnull NSString*) keyA retail application wants to remove the itemsAddedToCart user data after the product is purchased.
Objective C
[ACPUserProfile removeUserAttribute:@"itemsAddedToCart"];Swift
ACPUserProfile.removeUserAttribute("itemsAddedToCart");Removes the user profile attributes for the given keys.
+ (void) removeUserAttributes: (nonnull NSArray <NSString*>*) attributeNamesYou want to remove username, usertype user data when session timeout occurs.
Objective C
[ACPUserProfile removeUserAttributes:@[@"username", @"usertype"]]Swift
ACPUserProfile.removeUserAttributes(["username","usertype"]);{% endtab %}
{% tab title="Cordova" %}
Removes the user profile attribute for the given key.
ACPUserProfile.removeUserAttribute = function(attributeName, success, fail);- attributeName is a string containing the name of the user profile attribute to remove.
- success is a callback containing a general success message if the removeUserAttribute API executed without any errors.
- fail is a callback containing error information if the removeUserAttribute API was executed with errors.
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
ACPUserProfile.removeUserAttribute("itemsAddedToCart", handleCallback, handleError);Removes the user profile attributes for the given keys.
ACPUserProfile.removeUserAttributes = function(attributeNames, success, fail);- attributeNames is an array of strings containing the names of user profile attributes to remove.
- success is a callback containing a general success message if the removeUserAttributes API executed without any errors.
- fail is a callback containing error information if the removeUserAttributes API was executed with errors.
You want to remove username, usertype user data when session timeout occurs.
var attributeNames = new Array();
attributeNames.push("username");
attributeNames.push("usertype");
ACPUserProfile.removeUserAttributes(attributeNames, handleCallback, handleError);{% endtab %}
{% tab title="Flutter" %}
Removes the user profile attribute for the given key.
static Future<void> removeUserAttribute(String attributeName) async- attributeName is a string containing the name of the user profile attribute to remove.
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
FlutterACPUserProfile.removeUserAttribute("itemsAddedToCart");Removes the user profile attributes for the given keys.
static Future<void> removeUserAttributes(List<String> attributeName) async- attributeName is an array of strings containing the names of user profile attributes to remove.
You want to remove username, usertype user data when session timeout occurs.
FlutterACPUserProfile.removeUserAttributes(["username", "usertype"]){% endtab %}
{% tab title="Xamarin" %}
Removes the user profile attribute for the given key.
Android
public unsafe static void RemoveUserAttribute (string attributeName);- attributeName is a string containing the name of the user profile attribute to remove.
iOS
public static void RemoveUserAttribute (string attributeName);- attributeName is a string containing the name of the user profile attribute to remove.
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
ACPUserProfile.RemoveUserAttribute("itemsAddedToCart");Removes the user profile attributes for the given keys.
Android
public unsafe static void RemoveUserAttributes (IList<string> attributeNames);- attributeNames is an IList containing the names of user profile attributes to remove.
iOS
public static void RemoveUserAttributes (string[] attributeNames);- attributeNames is an array of strings containing the names of user profile attributes to remove.
You want to remove username, usertype user data when session timeout occurs.
Android
var attributes = new List<string>();
attributes.Add("username");
attributes.Add("usertype");
ACPUserProfile.RemoveUserAttributes(attributes);iOS
string[] attributes = new string[] { "username", "usertype" };
ACPUserProfile.RemoveUserAttributes(attributes);{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Android" %}
Gets the user profile attributes with the given keys.
public static void getUserAttributes(List<String> keys, AdobeCallback<Map<String, Object>> callback)- callback is invoked after the customer attributes are available.
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
}
});{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
Gets the user profile attributes with the given keys.
static func getUserAttributes(attributeNames: [String], completion: @escaping ([String: Any]?, AEPError) -> Void)- completion is the callback
functionwhich will be called with user attributes.
A retail application wants to get the itemsAddedToCart user data when processing checkout.
When the callback is provided, if the operation times out (5s) or an unexpected error occurs, the completion method is called with the appropriate AEPError.
UserProfile.getUserAttributes(attributeNames: ["itemsAddedToCart"]) { attributes, error in
// your customized code
}{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Gets the user profile attributes with the given keys.
+ (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.
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
}){% endtab %}
{% tab title="Cordova" %}
Gets the user profile attributes with the given keys.
ACPUserProfile.getUserAttributes = function(attributeNames, success, fail);- attributeNames is an array of strings containing the names of user profile attributes to retrieve.
- success is a callback containing the retrieved user profile attributes.
- fail is a callback containing error information if the getUserAttributes API was executed with errors.
A retail application wants to get the itemsAddedToCart user data when processing checkout.
var attributeNames = new Array();
attributeNames.push("itemsAddedToCart");
ACPUserProfile.getUserAttributes(attributeNames, handleCallback, handleError);{% endtab %}
{% tab title="Flutter" %}
Gets the user profile attributes with the given keys.
static Future<String> getUserAttributes(List<String> attributeKeys) async- attributeKeys is an array of strings containing the names of user profile attributes to retrieve.
A retail application wants to get the itemsAddedToCart user data when processing checkout.
try {
result = await FlutterACPUserProfile.getUserAttributes(["itemsAddedToCart"]);
} on PlatformException {
log("Failed to get the user attributes");
}{% endtab %}
{% tab title="Xamarin" %}
Gets the user profile attributes with the given keys.
Android
public unsafe static void GetUserAttributes (IList<string> keys, IAdobeCallback callback);- keys is an IList containing the names of user profile attributes to retrieve.
iOS
public unsafe static void GetUserAttributes (string[] attributNames, [BlockProxy (typeof(ObjCRuntime.Trampolines.NIDActionArity2V0))] Action<NSDictionary, NSError> completionHandler);- attributNames is an array of strings containing the names of user profile attributes to remove.
A retail application wants to get the itemsAddedToCart user data when processing checkout.
Android
var keysToRetrieve = new List<string>();
keysToRetrieve.Add("itemsAddedToCart");
ACPUserProfile.GetUserAttributes(keysToRetrieve, new AdobeCallback());
class AdobeCallback : Java.Lang.Object, IAdobeCallbackWithError
{
public void Fail(AdobeError error)
{
Console.WriteLine("GetUserAttributes error: " + error.ToString());
}
public void Call(Java.Lang.Object retrievedAttributes)
{
if (retrievedAttributes != null)
{
var attributesDictionary = new Android.Runtime.JavaDictionary<string, object>(retrievedAttributes.Handle, Android.Runtime.JniHandleOwnership.DoNotRegister);
foreach (KeyValuePair<string, object> pair in attributesDictionary)
{
Console.WriteLine("[ " + pair.Key + " : " + pair.Value + " ]");
}
}
else
{
Console.WriteLine("GetUserAttributes callback is null.");
}
}
}iOS
var callback = new Action<NSDictionary, NSError>(handleCallback);
var keysToRetrieve = new string[] { "itemsAddedToCart" };
ACPUserProfile.GetUserAttributes(keysToRetrieve, callback);
private void handleCallback(NSDictionary content, NSError error)
{
if (error != null)
{
Console.WriteLine("GetUserAttributes error: " + error.DebugDescription);
}
else if (content == null)
{
Console.WriteLine("GetUserAttributes callback is null.");
}
else
{
var attributesDictionary = (NSDictionary)content;
foreach (KeyValuePair<NSObject, NSObject> pair in attributesDictionary)
{
Console.WriteLine("[ " + pair.Key + " : " + pair.Value + " ]");
}
}
}{% endtab %} {% endtabs %}