Edit in GitHubLog an issue

API reference

extensionVersion

The extensionVersion() API returns the version of the Profile extension.

Java

Syntax

Copied to your clipboard
@NonNull public static String extensionVersion()

Example

Copied to your clipboard
String extensionVersion = UserProfile.extensionVersion();

Kotlin

Example

Copied to your clipboard
val extensionVersion = UserProfile.extensionVersion();

getUserAttributes

The getUserAttributes() API gets the user profile attributes with the given keys.

Java

Syntax

Copied to your clipboard
public 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 clipboard
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
}
});

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 clipboard
UserProfile.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
}
}
}

registerExtension

Registers the Profile extension with the Mobile Core extension.

Java

Syntax

Copied to your clipboard
@Deprecated
public static void registerExtension()

Example

Copied to your clipboard
import com.adobe.marketing.mobile.UserProfile
...
UserProfile.registerExtension();

removeUserAttribute

Deprecated as of 2.0.0. Please use the removeUserAttributes API instead.

Java

Syntax

Copied to your clipboard
@Deprecated
public 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 clipboard
UserProfile.removeUserAttribute("itemsAddedToCart");

removeUserAttributes

Removes the user profile attributes for the given keys.

Java

Syntax

Copied to your clipboard
public static void removeUserAttributes(@NonNull final List<String> attributeNames)

Example

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

Copied to your clipboard
UserProfile.removeUserAttributes(Arrays.asList("username", "usertype"));

Kotlin

Example

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

Copied to your clipboard
UserProfile.removeUserAttributes(listOf("username", "usertype"))

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.

Java

Syntax

Copied to your clipboard
@Deprecated
public 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 clipboard
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.

Java

Syntax

Copied to your clipboard
public 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 clipboard
HashMap<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 clipboard
val profileMap = mapOf(
"username" to "Will Smith",
"usertype" to "Actor"
)
UserProfile.updateUserAttributes(profileMap)
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.