Before you begin
- 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 Setup page for more details.
- Create a user session to be able to use QuickBlox functionality. See Authentication page to learn how to do it.
Create user
It’s recommended to manage user creation at your backend for production. To learn more you can refer to QuickBlox API documentation. For POCs/MVPs or during development you may want to create users on the fly, you can usecreate()
method.
Create a user using the code snippet below. Only login (or email) and password are required. Other fields are optional.
JavaScript
Security & PrivacyIt’s recommended to disable permission to create users with application session on production apps once user creation is implemented on your backend.Email, full name, facebookId and phone number are PII, configure session permissions according to your privacy requirements.
Retrieve users
Get a list of users using thegetUsers()
method below. The code snippet below shows how to get a list of users with full_name
containing John
, sorted by the updated_at
field in descending order, and limited to 10 users on the page.
JavaScript
getUsers()
accepts one (optional) argument of the object type that has the following fields:
Field | Required | Desription |
---|---|---|
filter | no | Specifies filtering criteria for the field. |
sort | no | Specifies sorting criteria for the field. |
page | no | Number of pages with results to be returned. |
perPage | no | Number of records to return in one page. |
Search operators
You can use search operators to get more specific search results. The request below will return users filtered by IDs.JavaScript
Search operators | Applicable to types | Applicable to fields | Description |
---|---|---|---|
lt | number, string, date | id, created_at, updated_at, last_request_at, external_user_id, facebook_id | Less Than operator. |
ge | number, string, date | id, created_at, updated_at, last_request_at, external_user_id, facebook_id | Greater Than or Equal to operator. |
gt | number, string, date | id, created_at, updated_at, last_request_at, external_user_id, facebook_id | Greater Than operator. |
le | number, string, date | id, created_at, updated_at, last_request_at, external_user_id, facebook_id | Less or Equal to operator |
eq | number, string, date | id, full_name, email, login, phone, created_at, updated_at, last_request_at, external_user_id, facebook_id | Equal to operator. |
ne | number, string, date | id, full_name, email, login, phone, created_at, updated_at, last_request_at, external_user_id, facebook_id | Not Equal to operator. |
between | number, string, date | id, created_at, updated_at, last_request_at, external_user_id, facebook_id | Contained between values operator. |
in | number, string, date | id, full_name, email, login, phone, created_at, updated_at, last_request_at, external_user_id, facebook_id | IN array operator. |
Sort operators
You can use sort operators to order the search results. The request below will return users sorted in descending order by the last date a user was requested.JavaScript
Sort options | Applicable to types | Applicable to fields | Description |
---|---|---|---|
ascending | All types | id, full_name, email, login, phone, website, created_at, updated_at,last_request_at, external_user_id | Sort results in the ascending order by setting the ascending as true. |
descending | All types | id, full_name, email, login, phone, website, created_at, updated_at,last_request_at, external_user_id | Sort results in the ascending order by setting the ascending as false. |
field | String, Number, Date | id, full_name, email, login, phone, website, created_at, updated_at, last_request_at, external_user_id | Sort Field Value |
type | String, Number, Date | id, full_name, email, login, phone, website, created_at, updated_at, last_request_at, external_user_id | Type of Sort Field Value |
Reset user password
This feature is coming soon. Please check back later. For more updates and questions, feel free to contact our Customer Support Team.
Update user
Update a user profile by calling theupdate()
method. If you want to change your password, you need to provide 2 parameters: password
and newPassword
. As a result, the updated user entity will be returned.
You can update any other field of the user using the updateUser()
method. Thus, the snippet below shows how to update a tagList
and customData
fields.
JavaScript
update()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
customData | no | User custom data. Should be a String. You can convert any data types to String. For example, JSON, XML, etc. |
tags | no | User tags. An array of Strings. A tag must include alphanumeric characters only and start with a letter. There are no spaces in the tag format. For example, the “tagOne” format is correct while the “tag one” format is incorrect. The maximum number of tags is 10. If more that 10 tags are provided, an error is returned: Error: tag list should contain maximum 10 tags |
Set user avatar
To set a user avatar, just upload a file to the QuickBlox cloud storage and connect it to the user. To upload the file to the QuickBlox cloud storage, call theupload()
method and pass the fileUrl
to it. The fileUrl
is a path to the file in the device filesystem. Now that the file is uploaded, get the ID of the uploaded file.
To connect the file to the user, set the ID of the uploaded file to the blobId
field of the user
and call the update()
method. As a result, the user avatar gets updated.
JavaScript
update()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
blobId | no | User blob ID. |
Get user avatar
You can also get access to the uploaded avatar of the user by calling thegetPrivateURL()
method. As a result, you will receive a private URL in the response. See this section to learn more about file URLs and getInfo()
method.
JavaScript
getPrivateUrl()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
uid | yes | A file unique indetifier. |