Skip to content

Get and Find Users

Get Current User

It is not possible to obtain the instance of a current user object, but SDK provides methods to read and update user properties via static class:

1
GetSocial.User.getDisplayName();
1
GetSocial.User.getDisplayName()
1
[GetSocialUser displayName];
1
GetSocialUser.displayName
1
GetSocial.User.DisplayName;
1
GetSocialUser.getDisplayName().then((displayName) => {});

Get User By ID

Public user profile is represented by PublicUser class. Object is read-only and provide access to name, avatar url, list of identities and public properties. Check entity reference for Android, iOS and Unity for more details.

The easiest way to get an instance of PublicUser is by GetSocial User Id:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
GetSocial.getUserById("GetSocial User Id", new Callback<PublicUser>() {
    @Override
    public void onSuccess(PublicUser publicUser) {
        // process user data
    }
    @Override
    public void onFailure(GetSocialException e) {
        // Ooops. There was some exception while getting other user details.
    }
});
1
2
3
4
5
6
7
8
9
GetSocial.getUserById("GetSocial User Id", object : Callback<PublicUser> {
    override fun onSuccess(publicUser: PublicUser) {
        // process user data
    }

    override fun onFailure(exception: GetSocialException) {
        // Ooops. There was some exception while getting other user details.
    }
})
1
2
3
4
5
[GetSocial userWithId:@"GetSocial User Id" success:^(GetSocialPublicUser * _Nonnull publicUser) {
    // process user data
} failure:^(NSError * _Nonnull error) {
    // Ooops. There was some error while getting other user details.
}];
1
2
3
4
5
GetSocial.user(withId: "GetSocial User Id", success: { publicUser in
    // process user data
}, failure: { error in
    // Ooops. There was some error while getting other user details.
})
1
2
3
4
5
6
7
8
9
GetSocial.GetUserById("GetSocial User Id",
    user =>
    {
        // process user data
    },
    error =>
    {
        // Ooops. There was some exception while getting other user details.
    });
1
2
3
4
5
GetSocial.getUserById('GetSocial User Id').then((publicUser) => {
    // process user data
}, (error) {
    // Ooops. There was some exception while getting other user details.
});

Also you can get users by their identities:

Find Users

You can find users by their display name:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
UsersQuery query = UsersQuery.usersByDisplayName("John Doe").withLimit(10);
GetSocial.findUsers(query, new Callback<List<UserReference>>() {
    @Override
    public void onSuccess(List<UserReference> users) {
        // Show list of users
    }

    @Override
    public void onFailure(GetSocialException exception) {
        // Error occured
    }
});
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
val query = UsersQuery.usersByDisplayName("John Doe").withLimit(10)
GetSocial.findUsers(query, object : Callback<List<UserReference>>{
    override fun onSuccess(users: List<UserReference>) {
        // Show list of users
    }

    override fun onFailure(exception: GetSocialException) {
        // Error occured
    }
})
1
2
3
4
5
6
7
8
9
GetSocialUsersQuery *usersQuery = [GetSocialUsersQuery usersByDisplayName:@"John Doe"];
[usersQuery setLimit:10];
[GetSocial findUsers:usersQuery
    success:^(NSArray<GetSocialUserReference *> *users) {
        // Show list of users
    }
    failure:^(NSError *error) {
        // Error occured
    }];
1
2
3
4
5
6
7
let usersQuery = GetSocialUsersQuery.users(byDisplayName: "John Doe")
usersQuery.setLimit(10)
GetSocial.findUsers(usersQuery, success: { users in
    // Show list of users
}, failure: { error in
    // Error occured
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
UsersQuery query = UsersQuery.UsersByDisplayName("John Doe").WithLimit(10);
GetSocial.FindUsers(query,
    users =>
    {
        // Show list of users
    },
    error =>
    {
        // Error occured
    });
1
2
3
4
5
6
const query = UsersQuery.usersByDisplayName('John Doe').withLimit(10);
GetSocial.findUsers(query).then((users) => {
    // Show list of users
}, (error) => {
    // Error occured
});

Next Steps

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

  • Connect your user with others using our Social Graph.
  • Post to global or custom news feeds and communicate with others with Activity Feed.

Give us your feedback! Was this article helpful?

😀 🙁