Profile API reference

extensionVersion

The extensionVersion() API returns the version of the Profile extension.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
React Native
Flutter
Cordova
Unity
Xamarin
Syntax
1
public static String extensionVersion()
Copied!
Example
1
String extensionVersion = UserProfile.extensionVersion();
Copied!

Swift

Syntax
1
static var extensionVersion: String
Copied!
Example
1
let extensionVersion = UserProfile.extensionVersion
Copied!

Objective-C

Syntax
1
+ (nonnull NSString*) extensionVersion;
Copied!
Example
1
NSString *extensionVersion = [AEPMobileUserProfile extensionVersion];
Copied!

Swift

Syntax
1
static var extensionVersion: String
Copied!
Example
1
let extensionVersion = ACPUserProfile.extensionVersion()
Copied!

Objective-C

Syntax
1
+ (nonnull NSString*) extensionVersion;
Copied!
Example
1
NSString *extensionVersion = [ACPUserProfile extensionVersion];
Copied!

JavaScript

1
ACPUserProfile.extensionVersion().then(extensionVersion => console.log("AdobeExperienceSDK: ACPUserProfile version: " + extensionVersion));
Copied!

Dart

1
String extensionVersion = await FlutterACPUserProfile.extensionVersion;
Copied!

Cordova

1
ACPUserProfile.extensionVersion(function(version) {
2
console.log("ACPUserProfile version: " + version);
3
}, function(error) {
4
console.log(error);
5
});
Copied!

C#

1
string extensionVersion = ACPUserProfile.ExtensionVersion();
Copied!

C#

1
string extensionVersion = ACPUserProfile.ExtensionVersion();
Copied!

getUserAttributes

The getUserAttributes() API gets the user profile attributes with the given keys.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
Cordova
Flutter
Xamarin
Syntax
1
public static void getUserAttributes(List<String> keys, AdobeCallback<Map<String, Object>> callback)
Copied!
  • 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.
1
UserProfile.getUserAttributes(Arrays.asList("itemsAddedToCart"), new AdobeCallbackWithError<Map<String, Object>>() {
2
@Override
3
public void fail(AdobeError adobeError) {
4
// your customized code
5
}
6
@Override
7
public void call(Map<String, Object> stringObjectMap) {
8
// your customized code
9
}
10
});
Copied!

Swift

Syntax
1
static func getUserAttributes(attributeNames: [String], completion: @escaping ([String: Any]?, AEPError) -> Void)
Copied!
  • completion is the callback function which will be called with user attributes.
Example
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.
1
UserProfile.getUserAttributes(attributeNames: ["itemsAddedToCart"]) { attributes, error in
2
// your customized code
3
}
Copied!

Objective-C

Syntax
1
+ (void)getUserAttributesWithAttributeNames:(NSArray<NSString *> * _Nonnull) comletion:^(NSDictionary<NSString *,id> * _Nullable, enum AEPError)
Copied!
Example
1
NSArray *attributes = @[@"itemsAddedToCart"];
2
[AEPMobileUserProfile getUserAttributesWithAttributeNames:attributes completion:^(NSDictionary<NSString *,id> * _Nullable, enum AEPError) {
3
// your customized code
4
}];
Copied!

Swift

Syntax
1
static func getUserAttributes(_ attributeNames: [String]?, withCompletionHandler completionHandler:([AnyHashable : Any]?, Error?) -> Void)
Copied!
  • 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.
Example
A retail application wants to get the itemsAddedToCart user data when processing checkout.
1
ACPUserProfile.getUserAttributes(["itemsAddedToCart"], withCompletionHandler: {(dict: [AnyHashable: Any]?, error: Error?) -> Void in
2
// your customized code
3
})
Copied!

Objective-C

Syntax
1
+ (void) getUserAttributes: (nullable NSArray <NSString*>*) attributNames withCompletionHandler: (nonnull void (^) (NSDictionary* __nullable userAttributes, NSError* _Nullable error)) completionHandler
Copied!
Example
1
[ACPUserProfile getUserAttributes:attributes withCompletionHandler:^(NSDictionary* dict, NSError* error){
2
// your customized code
3
}];
Copied!
Syntax
1
ACPUserProfile.getUserAttributes = function(attributeNames, success, fail);
Copied!
  • 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.
Example
A retail application wants to get the itemsAddedToCart user data when processing checkout.
1
var attributeNames = new Array();
2
attributeNames.push("itemsAddedToCart");
3
ACPUserProfile.getUserAttributes(attributeNames, handleCallback, handleError);
Copied!
Syntax
1
static Future<String> getUserAttributes(List<String> attributeKeys) async
Copied!
  • attributeKeys is an array of strings containing the names of user profile attributes to retrieve.
Example
A retail application wants to get the itemsAddedToCart user data when processing checkout.
1
try {
2
result = await FlutterACPUserProfile.getUserAttributes(["itemsAddedToCart"]);
3
} on PlatformException {
4
log("Failed to get the user attributes");
5
}
Copied!
Syntax
Android
1
public unsafe static void GetUserAttributes (IList<string> keys, IAdobeCallback callback);
Copied!
  • keys is an IList containing the names of user profile attributes to retrieve.
iOS
1
public unsafe static void GetUserAttributes (string[] attributNames, [BlockProxy (typeof(ObjCRuntime.Trampolines.NIDActionArity2V0))] Action<NSDictionary, NSError> completionHandler);
Copied!
  • attributNames is an array of strings containing the names of user profile attributes to remove.
Example
A retail application wants to get the itemsAddedToCart user data when processing checkout.
Android
1
var keysToRetrieve = new List<string>();
2
keysToRetrieve.Add("itemsAddedToCart");
3
ACPUserProfile.GetUserAttributes(keysToRetrieve, new AdobeCallback());
4
5
class AdobeCallback : Java.Lang.Object, IAdobeCallbackWithError
6
{
7
public void Fail(AdobeError error)
8
{
9
Console.WriteLine("GetUserAttributes error: " + error.ToString());
10
}
11
12
public void Call(Java.Lang.Object retrievedAttributes)
13
{
14
if (retrievedAttributes != null)
15
{
16
var attributesDictionary = new Android.Runtime.JavaDictionary<string, object>(retrievedAttributes.Handle, Android.Runtime.JniHandleOwnership.DoNotRegister);
17
foreach (KeyValuePair<string, object> pair in attributesDictionary)
18
{
19
Console.WriteLine("[ " + pair.Key + " : " + pair.Value + " ]");
20
}
21
}
22
else
23
{
24
Console.WriteLine("GetUserAttributes callback is null.");
25
}
26
}
27
}
Copied!
iOS
1
var callback = new Action<NSDictionary, NSError>(handleCallback);
2
var keysToRetrieve = new string[] { "itemsAddedToCart" };
3
ACPUserProfile.GetUserAttributes(keysToRetrieve, callback);
4
5
private void handleCallback(NSDictionary content, NSError error)
6
{
7
if (error != null)
8
{
9
Console.WriteLine("GetUserAttributes error: " + error.DebugDescription);
10
}
11
else if (content == null)
12
{
13
Console.WriteLine("GetUserAttributes callback is null.");
14
}
15
else
16
{
17
var attributesDictionary = (NSDictionary)content;
18
foreach (KeyValuePair<NSObject, NSObject> pair in attributesDictionary)
19
{
20
Console.WriteLine("[ " + pair.Key + " : " + pair.Value + " ]");
21
}
22
}
23
}
Copied!

registerExtension

Registers the Profile extension with the Mobile Core extension.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)

Java

Syntax
1
public static void registerExtension()
Copied!
Example
1
import com.adobe.marketing.mobile.UserProfile
2
3
...
4
5
UserProfile.registerExtension();
Copied!
In iOS, the registration occurs by passing UserProfile extension to the MobileCore.registerExtensions API.

Swift

Syntax
1
static func registerExtensions(_ extensions: [NSObject.Type],
2
_ completion: (() -> Void)? = nil)
Copied!
Example
1
import AEPUserProfile
2
3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4
5
MobileCore.registerExtensions([UserProfile.self])
6
// Override point for customization after application launch.
7
return true;
8
}
Copied!

Objective-C

Syntax
1
+ (void) registerExtensions: (NSArray<Class*>* _Nonnull) extensions
2
completion: (void (^ _Nullable)(void)) completion;
Copied!
Example
1
@import AEPUserProfile;
2
3
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
4
5
[AEPMobileCore registerExtensions:@[AEPMobileUserProfile.class] completion:nil];
6
// Override point for customization after application launch.
7
return YES;
8
}
Copied!
Register the Identity extension in your app's didFinishLaunchingWithOptions function:

Swift

Syntax
1
static func registerExtensions()
Copied!
Example
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
ACPUserProfile.registerExtension()
3
// Override point for customization after application launch.
4
return true;
5
}
Copied!

Objective-C

Syntax
1
+ (void) registerExtension;
Copied!
Example
1
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2
[ACPUserProfile registerExtension];
3
// Override point for customization after application launch.
4
return YES;
5
}
Copied!

removeUserAttribute

Removes the user profile attribute for the given key.
Android
iOS (ACP 2.x)
Cordova
Flutter
Xamarin
Syntax
1
public static void removeUserAttribute(String attributeName)
Copied!
Example
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
1
UserProfile.removeUserAttribute("itemsAddedToCart");
Copied!

Swift

Syntax
1
static func removeUserAttribute(_ attributeName: String)
Copied!
Example
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
1
ACPUserProfile.removeUserAttribute("itemsAddedToCart");
Copied!

Objective-C

Syntax
1
+ (void) removeUserAttribute: (nonnull NSString*) key
Copied!
Example
1
[ACPUserProfile removeUserAttribute:@"itemsAddedToCart"];
Copied!
Syntax
1
ACPUserProfile.removeUserAttribute = function(attributeName, success, fail);
Copied!
  • 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.
Example
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
1
ACPUserProfile.removeUserAttribute("itemsAddedToCart", handleCallback, handleError);
Copied!
Syntax
1
static Future<void> removeUserAttribute(String attributeName) async
Copied!
  • attributeName is a string containing the name of the user profile attribute to remove.
Example
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
1
FlutterACPUserProfile.removeUserAttribute("itemsAddedToCart");
Copied!
Syntax
Android
1
public unsafe static void RemoveUserAttribute (string attributeName);
Copied!
  • attributeName is a string containing the name of the user profile attribute to remove.
iOS
1
public static void RemoveUserAttribute (string attributeName);
Copied!
  • attributeName is a string containing the name of the user profile attribute to remove.
Example
A retail application wants to remove the itemsAddedToCart user data after the product is purchased.
1
ACPUserProfile.RemoveUserAttribute("itemsAddedToCart");
Copied!

removeUserAttributes

Removes the user profile attributes for the given keys.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
Cordova
Flutter
Xamarin
Syntax
1
public static void removeUserAttributes(List<String> attributeNames)
Copied!
Example
You want to remove username, usertype user data when session timeout occurs.
1
UserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
Copied!

Swift

Syntax
1
public static void removeUserAttributes(List<String> attributeNames)
Copied!
Example
You want to remove username, usertype user data when session timeout occurs.
1
UserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
Copied!

Objective-C

Syntax
1
+ (void) removeUserAttributesWithAttributeNames:(NSArray<NSString *> * _Nonnull)
Copied!
Example
1
[AEPMobileUserProfile removeUserAttributesWithAttributeNames:@[@"username", @"usertype"]]
Copied!

Swift

Syntax
1
static func removeUserAttributes(_ attributeNames: [String]?)
Copied!
Example
You want to remove username, usertype user data when session timeout occurs.
1
ACPUserProfile.removeUserAttributes(["username","usertype"]);
Copied!

Objective-C

Syntax
1
+ (void) removeUserAttributes: (nonnull NSArray <NSString*>*) attributeNames
Copied!
Example
1
[ACPUserProfile removeUserAttributes:@[@"username", @"usertype"]]
Copied!
Syntax
1
ACPUserProfile.removeUserAttributes = function(attributeNames, success, fail);
Copied!
  • 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.
Example
You want to remove username, usertype user data when session timeout occurs.
1
var attributeNames = new Array();
2
attributeNames.push("username");
3
attributeNames.push("usertype");
4
ACPUserProfile.removeUserAttributes(attributeNames, handleCallback, handleError);
Copied!
Syntax
1
static Future<void> removeUserAttributes(List<String> attributeName) async
Copied!
  • attributeName is an array of strings containing the names of user profile attributes to remove.
Example
You want to remove username, usertype user data when session timeout occurs.
1
FlutterACPUserProfile.removeUserAttributes(["username", "usertype"])
Copied!
Syntax
Android
1
public unsafe static void RemoveUserAttributes (IList<string> attributeNames);
Copied!
  • attributeNames is an IList containing the names of user profile attributes to remove.
iOS
1
public static void RemoveUserAttributes (string[] attributeNames);
Copied!
  • attributeNames is an array of strings containing the names of user profile attributes to remove.
Example
You want to remove username, usertype user data when session timeout occurs.
Android
1
var attributes = new List<string>();
2
attributes.Add("username");
3
attributes.Add("usertype");
4
ACPUserProfile.RemoveUserAttributes(attributes);
Copied!
iOS
1
string[] attributes = new string[] { "username", "usertype" };
2
ACPUserProfile.RemoveUserAttributes(attributes);
Copied!

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.
Android
iOS (ACP 2.x)
Cordova
Flutter
Xamarin
Syntax
1
public static void updateUserAttribute(String attributeName,
2
Object attributeValue)
Copied!
Example
You want to update username of a user obtained in the log in page :
1
UserProfile.updateUserAttribute("username", "Will Smith");
Copied!

Swift

Syntax
1
static func updateUserAttribute(_ attributeName: String, withValue attributeValue: String?)
Copied!
Example
You want to update username of a user obtained in the log in page:
1
ACPUserProfile.updateUserAttribute("username", withValue: "Will Smith");
Copied!

Objective-C

Syntax
1
+ (void) updateUserAttribute: (nonnull NSString*) attributeName withValue: (nullable NSString*) attributeValue;
Copied!
Example
1
[ACPUserProfile updateUserAttribute:@"username" withValue:@"Will Smith"];
Copied!
Syntax
1
ACPUserProfile.updateUserAttribute = function(attributeName, attributeValue, success, fail);
Copied!
  • 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.
Example
You want to update username of a user obtained in the log in page :
1
ACPUserProfile.updateUserAttribute("username", "Will Smith", handleCallback, handleError);
Copied!
Syntax
1
static Future<void> updateUserAttribute(String attributeName, String attributeValue) async
Copied!
  • 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.
Example
You want to update username of a user obtained in the log in page :
1
FlutterACPUserProfile.updateUserAttribute("username", "Will Smith");
Copied!
Syntax
Android
1
public unsafe static void UpdateUserAttribute (string attributeName, Java.Lang.Object attributeValue);
Copied!
  • 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 UserProfile attribute.
iOS
1
public static void UpdateUserAttribute (string attributeName, string attributeValue);
Copied!
  • 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.
Example
You want to update username of a user obtained in the log in page :
1
ACPUserProfile.updateUserAttribute("username", "Will Smith");
Copied!

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.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
Cordova
Flutter
Xamarin
Syntax
1
public static void updateUserAttributes(Map<String, Object> attributeMap)
Copied!
Example
You want to update username, usertype of a user obtained in the log in page :
1
HashMap<String, Object> profileMap = new HashMap<>();
2
profileMap.put("username","Will Smith");
3
profileMap.put("usertype","Actor");
4
UserProfile.updateUserAttributes(profileMap);
Copied!

Swift

Syntax
1
public static func updateUserAttributes(attributeDict: [String: Any])
Copied!
Example
You want to update username, usertype of a user obtained in the log in page :
1
var profileMap = [AnyHashable: Any]()
2
profileMap["username"] = "will_smith"
3
profileMap["usertype"] = "Actor"
4
UserProfile.updateUserAttributes(attributeDict: profileMap)
Copied!

Objective-C

Syntax
1
+ (void)updateUserAttributesWithAttributeDict:(NSDictionary<NSString *,id> * _Nonnull)
Copied!
Example
1
NSMutableDictionary *profileMap = [NSMutableDictionary dictionary];
2
[profileMap setObject:@"username" forKey:@"will_smith"];
3
[profileMap setObject:@"usertype" forKey:@"Actor"];
4
[AEPMobileUserProfile updateUserAttributesWithAttributeDict:profileMap];
Copied!

Swift

Syntax
1
static func updateUserAttributes(_ attributeMap: [AnyHashble: Any])
Copied!
Example
You want to update username, usertype of a user obtained in the log in page :
1
var profileMap = [AnyHashable: Any]()
2
profileMap["username"] = "will_smith"
3
profileMap["usertype"] = "Actor"
4
ACPUserProfile.updateUserAttributes(profileMap)
Copied!

Objective-C

Syntax
1
+ (void) updateUserAttributes: (nonnull NSDictionary*) attributeMap
Copied!
Example
1
NSMutableDictionary *profileMap = [NSMutableDictionary dictionary];
2
[profileMap setObject:@"username" forKey:@"will_smith"];
3
[profileMap setObject:@"usertype" forKey:@"Actor"];
4
[ACPUserProfile updateUserAttributes:profileMap];
Copied!
Syntax
1
ACPUserProfile.updateUserAttributes = function(attributes, success, fail);
Copied!
  • 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.
Example
You want to update username, usertype of a user obtained in the log in page :
1
var username = "will_smith";
2
var usertype = "Actor";
3
var attributes = {"username":username, "usertype":usertype};
4
ACPUserProfile.updateUserAttributes(attributes, handleCallback, handleError);
Copied!
Syntax
1
static Future<void> updateUserAttributes(Map<String, Object> attributeMap) async
Copied!
  • attributeMap is a object containing a batch of user profile attributes to create or update.
Example
You want to update username, usertype of a user obtained in the log in page :
1
FlutterACPUserProfile.updateUserAttributes({"username":"will_smith", "usertype":"Actor"});
Copied!
Syntax
Android
1
public unsafe static void UpdateUserAttributes (IDictionary<string, Java.Lang.Object> attributeMap);
Copied!
  • attributeMap is a object containing a batch of user profile attributes to create or update.
iOS
1
public static void UpdateUserAttributes (NSDictionary attributeMap);
Copied!
  • attributeMap is a object containing a batch of user profile attributes to create or update.
Example
You want to update username, usertype of a user obtained in the log in page :
Android
1
var attributes = new Dictionary<string, Java.Lang.Object>();
2
attributes.Add("username", "will_smith");
3
attributes.Add("usertype", "Actor");
4
ACPUserProfile.UpdateUserAttributes(attributes);
Copied!
iOS
1
var attributes = new NSMutableDictionary<NSString, NSString>
2
{
3
["username"] = new NSString("will_smith"),
4
["usertype"] = new NSString("Actor")
5
};
6
ACPUserProfile.updateUserAttributes(attributes);
Copied!