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];
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 clipboard@Deprecatedpublic static void registerExtension()
Example
Copied to your clipboardimport com.adobe.marketing.mobile.UserProfile...UserProfile.registerExtension();
On iOS, the registration occurs by passing UserProfile extension to the MobileCore.registerExtensions API.
Swift
Syntax
Copied to your clipboardstatic func registerExtensions(_ extensions: [NSObject.Type],_ completion: (() -> Void)? = nil)
Example
Copied to your clipboardimport AEPUserProfilefunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {MobileCore.registerExtensions([UserProfile.self])// Override point for customization after application launch.return true;}
Objective-C
Syntax
Copied to your clipboard+ (void) registerExtensions: (NSArray<Class*>* _Nonnull) extensionscompletion: (void (^ _Nullable)(void)) completion;
Example
Copied to your clipboard@import AEPUserProfile;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[AEPMobileCore registerExtensions:@[AEPMobileUserProfile.class] completion:nil];// Override point for customization after application launch.return YES;}
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 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 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 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];