API reference
extensionVersion
The extensionVersion()
API returns the version of the Profile extension.
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet extensionVersion = UserProfile.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *extensionVersion = [AEPMobileUserProfile extensionVersion];
Java
Syntax
Copied to your clipboard@NonNull public static String extensionVersion()
Example
Copied to your clipboardString extensionVersion = UserProfile.extensionVersion();
Kotlin
Example
Copied to your clipboardval extensionVersion = UserProfile.extensionVersion();
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet extensionVersion = UserProfile.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *extensionVersion = [AEPMobileUserProfile extensionVersion];
getUserAttributes
The getUserAttributes()
API gets the user profile attributes with the given keys.
Java
Syntax
Copied to your clipboardpublic static void getUserAttributes(@NonNull final List<String> keys, @NonNull final 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
.
Copied to your clipboardUserProfile.getUserAttributes(Arrays.asList("itemsAddedToCart"), new AdobeCallbackWithError<Map<String, Object>>() {@Overridepublic void fail(AdobeError adobeError) {// your customized code}@Overridepublic void call(Map<String, Object> stringObjectMap) {// your customized code}});
Kotlin
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
.
Copied to your clipboardUserProfile.getUserAttributes(listOf("itemsAddedToCart")) {object : AdobeCallbackWithError<Map<String, Any?>> {override fun fail(adobeError: AdobeError) {// your customized code}override fun call(value: Map<String, Any?>) {// your customized code}}}
Swift
Syntax
Copied to your clipboardstatic func getUserAttributes(attributeNames: [String], completion: @escaping ([String: Any]?, AEPError) -> Void)
- 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
.
Copied to your clipboardUserProfile.getUserAttributes(attributeNames: ["itemsAddedToCart"]) { attributes, error in// your customized code}
Objective-C
Syntax
Copied to your clipboard+ (void)getUserAttributesWithAttributeNames:(NSArray<NSString *> * _Nonnull) comletion:^(NSDictionary<NSString *,id> * _Nullable, enum AEPError)
Example
Copied to your clipboardNSArray *attributes = @[@"itemsAddedToCart"];[AEPMobileUserProfile getUserAttributesWithAttributeNames:attributes completion:^(NSDictionary<NSString *,id> * _Nullable, enum AEPError) {// your customized code}];
Java
Syntax
Copied to your clipboardpublic static void getUserAttributes(@NonNull final List<String> keys, @NonNull final 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
.
Copied to your clipboardUserProfile.getUserAttributes(Arrays.asList("itemsAddedToCart"), new AdobeCallbackWithError<Map<String, Object>>() {@Overridepublic void fail(AdobeError adobeError) {// your customized code}@Overridepublic void call(Map<String, Object> stringObjectMap) {// your customized code}});
Kotlin
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
.
Copied to your clipboardUserProfile.getUserAttributes(listOf("itemsAddedToCart")) {object : AdobeCallbackWithError<Map<String, Any?>> {override fun fail(adobeError: AdobeError) {// your customized code}override fun call(value: Map<String, Any?>) {// your customized code}}}
Swift
Syntax
Copied to your clipboardstatic func getUserAttributes(attributeNames: [String], completion: @escaping ([String: Any]?, AEPError) -> Void)
- 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
.
Copied to your clipboardUserProfile.getUserAttributes(attributeNames: ["itemsAddedToCart"]) { attributes, error in// your customized code}
Objective-C
Syntax
Copied to your clipboard+ (void)getUserAttributesWithAttributeNames:(NSArray<NSString *> * _Nonnull) comletion:^(NSDictionary<NSString *,id> * _Nullable, enum AEPError)
Example
Copied to your clipboardNSArray *attributes = @[@"itemsAddedToCart"];[AEPMobileUserProfile getUserAttributesWithAttributeNames:attributes completion:^(NSDictionary<NSString *,id> * _Nullable, enum AEPError) {// your customized code}];
registerExtension
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use MobileCore.registerExtensions()
API instead.
Registers the Profile extension with the Mobile Core extension.
removeUserAttribute
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use removeUserAttributes
API instead.
Deprecated as of 2.0.0. Please use the removeUserAttributes API instead.
Android
Java
Syntax
Copied to your clipboard@Deprecatedpublic static void removeUserAttribute(@NonNull final String attributeName)
Example
A retail application wants to remove the itemsAddedToCart
user data after the product is purchased.
Copied to your clipboardUserProfile.removeUserAttribute("itemsAddedToCart");
Java
Syntax
Copied to your clipboard@Deprecatedpublic static void removeUserAttribute(@NonNull final String attributeName)
Example
A retail application wants to remove the itemsAddedToCart
user data after the product is purchased.
Copied to your clipboardUserProfile.removeUserAttribute("itemsAddedToCart");
removeUserAttributes
Removes the user profile attributes for the given keys.
Java
Syntax
Copied to your clipboardpublic static void removeUserAttributes(@NonNull final List<String> attributeNames)
Example
You want to remove username
, usertype
user data when session timeout occurs.
Copied to your clipboardUserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
Kotlin
Example
You want to remove username
, usertype
user data when session timeout occurs.
Copied to your clipboardUserProfile.removeUserAttributes(listOf("username", "usertype"))
Swift
Syntax
Copied to your clipboardpublic static void removeUserAttributes(List<String> attributeNames)
Example
You want to remove username
, usertype
user data when session timeout occurs.
Copied to your clipboardUserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
Objective-C
Syntax
Copied to your clipboard+ (void) removeUserAttributesWithAttributeNames:(NSArray<NSString *> * _Nonnull)
Example
Copied to your clipboard[AEPMobileUserProfile removeUserAttributesWithAttributeNames:@[@"username", @"usertype"]]
Java
Syntax
Copied to your clipboardpublic static void removeUserAttributes(@NonNull final List<String> attributeNames)
Example
You want to remove username
, usertype
user data when session timeout occurs.
Copied to your clipboardUserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
Kotlin
Example
You want to remove username
, usertype
user data when session timeout occurs.
Copied to your clipboardUserProfile.removeUserAttributes(listOf("username", "usertype"))
Swift
Syntax
Copied to your clipboardpublic static void removeUserAttributes(List<String> attributeNames)
Example
You want to remove username
, usertype
user data when session timeout occurs.
Copied to your clipboardUserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));
Objective-C
Syntax
Copied to your clipboard+ (void) removeUserAttributesWithAttributeNames:(NSArray<NSString *> * _Nonnull)
Example
Copied to your clipboard[AEPMobileUserProfile removeUserAttributesWithAttributeNames:@[@"username", @"usertype"]]
updateUserAttribute
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use updateUserAttributes
API instead.
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
Java
Syntax
Copied to your clipboard@Deprecatedpublic static void updateUserAttribute(@NonNull final String attributeName, @Nullable final Object attributeValue)
Example
You want to update username
of a user obtained in the log in page:
Copied to your clipboardUserProfile.updateUserAttribute("username", "Will Smith");
Java
Syntax
Copied to your clipboard@Deprecatedpublic static void updateUserAttribute(@NonNull final String attributeName, @Nullable final Object attributeValue)
Example
You want to update username
of a user obtained in the log in page:
Copied to your clipboardUserProfile.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.
Java
Syntax
Copied to your clipboardpublic static void updateUserAttributes(@NonNull final Map<String, Object> attributeMap)
Example
You want to update username
, usertype
of a user obtained in the log in page:
Copied to your clipboardHashMap<String, Object> profileMap = new HashMap<>();profileMap.put("username","Will Smith");profileMap.put("usertype","Actor");UserProfile.updateUserAttributes(profileMap);
Kotlin
Example
You want to update username
, usertype
of a user obtained in the log in page:
Copied to your clipboardval profileMap = mapOf("username" to "Will Smith","usertype" to "Actor")UserProfile.updateUserAttributes(profileMap)
Swift
Syntax
Copied to your clipboardpublic static func updateUserAttributes(attributeDict: [String: Any])
Example
You want to update username, usertype
of a user obtained in the log in page:
Copied to your clipboardvar profileMap = [AnyHashable: Any]()profileMap["username"] = "will_smith"profileMap["usertype"] = "Actor"UserProfile.updateUserAttributes(attributeDict: profileMap)
Objective-C
Syntax
Copied to your clipboard+ (void)updateUserAttributesWithAttributeDict:(NSDictionary<NSString *,id> * _Nonnull)
Example
Copied to your clipboardNSMutableDictionary *profileMap = [NSMutableDictionary dictionary];[profileMap setObject:@"username" forKey:@"will_smith"];[profileMap setObject:@"usertype" forKey:@"Actor"];[AEPMobileUserProfile updateUserAttributesWithAttributeDict:profileMap];
Java
Syntax
Copied to your clipboardpublic static void updateUserAttributes(@NonNull final Map<String, Object> attributeMap)
Example
You want to update username
, usertype
of a user obtained in the log in page:
Copied to your clipboardHashMap<String, Object> profileMap = new HashMap<>();profileMap.put("username","Will Smith");profileMap.put("usertype","Actor");UserProfile.updateUserAttributes(profileMap);
Kotlin
Example
You want to update username
, usertype
of a user obtained in the log in page:
Copied to your clipboardval profileMap = mapOf("username" to "Will Smith","usertype" to "Actor")UserProfile.updateUserAttributes(profileMap)
Swift
Syntax
Copied to your clipboardpublic static func updateUserAttributes(attributeDict: [String: Any])
Example
You want to update username, usertype
of a user obtained in the log in page:
Copied to your clipboardvar profileMap = [AnyHashable: Any]()profileMap["username"] = "will_smith"profileMap["usertype"] = "Actor"UserProfile.updateUserAttributes(attributeDict: profileMap)
Objective-C
Syntax
Copied to your clipboard+ (void)updateUserAttributesWithAttributeDict:(NSDictionary<NSString *,id> * _Nonnull)
Example
Copied to your clipboardNSMutableDictionary *profileMap = [NSMutableDictionary dictionary];[profileMap setObject:@"username" forKey:@"will_smith"];[profileMap setObject:@"usertype" forKey:@"Actor"];[AEPMobileUserProfile updateUserAttributesWithAttributeDict:profileMap];