Skip to content

Manage User Profile

To check or update details of the current user profile:

val currentUser = GetSocial.getCurrentUser()
if (currentUser == null) {
    // SDK is not initialized yet
    return
}
// use currentUser object
guard let currentUser = GetSocial.currentUser() else {
    // SDK is not initialized yet
    return
}
// use currentUser object
var currentUser = GetSocial.GetCurrentUser();
if (currentUser == null)
{
    // SDK is not initialized yet
    return;
}
// use currentUser object
var currentUser = await GetSocial.currentUser;
if (currentUser == null) {
    // SDK is not initialized yet
    return;
}
// use currentUser object
const currentUser = await GetSocial.getCurrentUser();
if (currentUser == null) {
    // SDK is not initialized yet
    return;
}
// use currentUser object
const currentUser = GetSocialSDK.GetSocial.getCurrentUser();
if (currentUser == null) {
    // User is not authenticated yet
    return;
}
// use currentUser object

Getters

// couple of examples
val displayName = currentUser.displayName
val avatarUrl = currentUser.avatarUrl
val publicProperties = currentUser.publicProperties
val privatProperties = currentUser.privateProperties
val identities = currentUser.identities
// couple of examples
let displayName = currentUser.displayName
let avatarUrl = currentUser.avatarUrl
let publicProperties = currentUser.publicProperties
let privatProperties = currentUser.privateProperties
let identities = currentUser.identities
// couple of examples
var displayName = currentUser.DisplayName;
var avatarUrl = currentUser.AvatarUrl;
var publicProperties = currentUser.PublicProperties;
var privateProperties = currentUser.PrivateProperties;
var identities = currentUser.Identities;
// couple of examples
var displayName = currentUser.displayName;
var avatarUrl = currentUser.avatarUrl;
var publicProperties = currentUser.publicProperties;
var privateProperties = currentUser.privateProperties;
var identities = currentUser.identities;
// couple of examples
var displayName = currentUser.displayName;
var avatarUrl = currentUser.avatarUrl;
var publicProperties = currentUser.publicProperties;
var privateProperties = currentUser.privateProperties;
var identities = currentUser.identities;
// couple of examples
var displayName = currentUser.displayName;
var avatarUrl = currentUser.avatarUrl;
var publicProperties = currentUser.publicProperties;
var privateProperties = currentUser.privateProperties;
var identities = currentUser.identities;

Properties Update

To update the user profile use UserUpdate class. It allows you update few user properties(custom and not) in one request:

val batchUpdate = UserUpdate()
    .updateAvatarUrl(newAvatarUrl)
    .updateDisplayName(newDisplayName)
    .setPublicProperty(publicProperty1, newPublicValue)
    .removePublicProperty(publicProperty2)
    .setPrivateProperty(privateProperty1, newPrivateValue)
    .removePrivateProperty(privateProperty2)

curentUser.updateDetails(batchUpdate, {
    Log.d("CurrentUser", "User details were successfully updated")
}, { error ->
    Log.d("CurrentUser", "Failed to update user details, error: ${error}")
})
var batchUpdate = UserUpdate()
batchUpdate.avatarUrl = newAvatarUrl
batchUpdate.displayName = newDisplayName
batchUpdate.setPublicProperty(value: newPublicValue, key: publicProperty1)
batchUpdate.removePublicProperty(publicProperty2)
batchUpdate.setPrivateProperty(value: privateProperty1, forKey: newPrivateValue)
batchUpdate.removePrivateProperty(privateProperty2)

currentUser.updateDetails(batchUpdate, success: success, failure: failure)
var batchUpdate = new UserUpdate();
batchUpdate.AvatarUrl = newAvatarUrl
batchUpdate.DisplayName = newDisplayName
batchUpdate.AddPublicProperty(publicProperty1, newPublicValue);
batchUpdate.RemovePublicProperty(publicProperty2);
batchUpdate.AddPrivateProperty(newPrivateValue, privateProperty1);
batchUpdate.RemovePrivateProperty(privateProperty2);
currentUser.UpdateDetails(batchUpdate, OnSuccess, OnFailure);
var batchUpdate = UserUpdate();
batchUpdate.updateAvatarUrl(newAvatarUrl);
batchUpdate.updateDisplayName(newDisplayName);
batchUpdate.setPublicProperty(publicProperty1, newPublicValue);
batchUpdate.removePublicProperty(publicProperty2);
batchUpdate.setPrivateProperty(newPrivateValue, privateProperty1);
batchUpdate.removePrivateProperty(privateProperty2);
var currentUser = await GetSocial.currentUser;
currentUser.updateDetails(batchUpdate);
var batchUpdate = new UserUpdate();
batchUpdate.avatarUrl = newAvatarUrl;
batchUpdate.displayName = newDisplayName;
batchUpdate.publicProperties[publicProperty1] = newPublicValue;
batchUpdate.privateProperies[newPrivateValue] = privateProperty1;
const currentUser = await GetSocial.getCurrentUser();
currentUser.updateDetails(batchUpdate);
var batchUpdate = new GetSocialSDK.UserUpdate();
batchUpdate.avatarUrl = newAvatarUrl;
batchUpdate.displayName = newDisplayName;
batchUpdate.publicProperties[publicProperty1] = newPublicValue;
batchUpdate.privateProperies[newPrivateValue] = privateProperty1;
const currentUser = GetSocialSDK.GetSocial.getCurrentUser();
currentUser.updateDetails(batchUpdate);

Reference

You can read about CurrentUser methods in the reference for Android and iOS.

Next Steps

Well-done! Your user is set up, see what to do next:

Give us your feedback! Was this article helpful?

😀 🙁