This is our new documentation for beta version of QuickBlox React Native SDK. Please contact our Customer Support Team to provide your feedback, suggestions, and requests to improve this page.
The user module manages all things related to user accounts handling, authentication, account data, password remind, etc.
Before you begin
- Visit our Key Concepts page to get an overall understanding of the most important QuickBlox concepts.
- Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
- Configure QuickBlox SDK for your app. Check out our Setup page for more details.
- Create a user session to be able to use QuickBlox functionality. See our Authentication page to learn how to do it.
Create user
Create a user using the code snippet below. Only login (or email) and password are required. Other fields are optional.
QB.users
.create({
email: '[email protected]',
fullName: 'Jack Sparrow',
login: 'jack',
password: 'jackpassword',
phone: '404-388-5366',
tags: [ '#awesome', '#quickblox' ]
})
.then(function (user) {
// user created successfully
})
.catch(function (e) {
// handle as necessary
});
Update user
Update a user profile using the following code snippet. If you want to change your password, you need to provide 2 parameters: password
and newPassword
. The updated user
entity will be returned.
user.fullName = "Monro";
user.email = "[email protected]";
QB.users
.update({ user: user })
.then(function (updatedUser) {
// update local user with updated one
})
.catch(function (e) {
// handle error
});
Retrieve users
Retrieve users by ID
To get a list of users by ID for a current account, use the following code snippet.
const occupantsIds = dialog.occupantsIds;
const filter = {
field: QB.users.USERS_FILTER.FIELD.ID,
type: QB.users.USERS_FILTER.TYPE.NUMBER,
operator: QB.users.USERS_FILTER.OPERATOR.IN,
value: occupantsIds.join()
};
QB.users
.getUsers({ filter: filter })
.then(function (result) {
// result.users - array of users found by provided IDs
// result.page - page of results
// result.perPage - how much items returned per page
// result.total - total amount of items
})
.catch(function (e) {
// handle error
});
Retrieve users by full name
To get a list of users by full name for a current account, use the following code snippet.
const filter = {
field: QB.users.USERS_FILTER.FIELD.FULL_NAME,
operator: QB.users.USERS_FILTER.OPERATOR.IN,
type: QB.users.USERS_FILTER.TYPE.STRING,
value: 'filter'
};
QB.users
.getUsers({ filter: filter })
.then(function (result) {
// users found
})
.catch(function (e) {
// handle error
});
Updated 4 months ago
What's Next
Chat |