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 usesignUp() method.
Create a user using the code snippet below. Only login (or email) and password are required. Other fields are optional.
- Swift
- Objective-C
Retrieve users
Get a list of users using theusers(withExtendedRequest:page:) method. The code snippet below shows how to get a list of users created between the two given dates and sorted in descending order.
- Swift
- Objective-C
If you want to retrieve only users updated after some specific date time, you can use operators. This is useful if you cache users somehow and do not want to obtain the whole list of users on every app start. Thus, you can use search and sort operators to list users on the page so that it is easier to see specific users.
Search operators
You can use search operators to get more specific search results. The request below will return a list of users created between the two given dates.- Swift
- Objective-C
Sort operators
You can use sort operators to order the search results. The request below will return a list of users sorted in descending order by thecreated_at field.
- Swift
- Objective-C
Retrieve users by ID
To get a list of users by ID for a current account, use the following code snippet.- Swift
- Objective-C
Retrieve user by login
To get a list of users by login for a current account, use the following code snippet.- Swift
- Objective-C
Retrieve user by email
To get a list of users by email for a current account, use the following code snippet.- Swift
- Objective-C
Retrieve users by full name
To get a list of users found by the server according to the search query, use the following code snippet. Search requires min 3 characters.- Swift
- Objective-C
Retrieve users by phone number
To get a list of users by phone number for a current account, use the following code snippet.- Swift
- Objective-C
Retrieve user by external user ID
If you have your own database with users (we call these databases as “external databases”), you can use External User ID (ExternalID field) in QBUser model to link users from QuickBlox with users from your external database.
- Swift
- Objective-C
Retrieve users by tags
To get a list of users by tags for a current account, use the following code snippet.- Swift
- Objective-C
Delete user
A user can delete himself from the platform.- Swift
- Objective-C
Reset user password
It’s possible to reset a password via email.- Swift
- Objective-C
Make sure to enable the email confirmation. This functionality allows application users to confirm their emails. If a user doesn’t confirm the email, the emails won’t be sent to this user. As a result, a password reset functionality won’t work. To enable the email confirmation, proceed as follows:
- Go to the Dashboard => YOUR_APP => Users => Settings => User registration confirmation and check the box.
- Click the Save button.
Update user
Update a user profile by calling theupdateUser() method. If you want to change your password, you need to provide 2 parameters: password and oldPassword. 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.
- Swift
- Objective-C
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, just convert the file to the date format and upload it to the QuickBlox cloud storage by calling thetUploadFile(fileName:contentType:isPublic:) method. In the response, the uploadedBlob object is returned by the server. Get the blob UID from the uploadedBlob object.
To connect the file to the user, set the blob UID in the customData field of the user model and call the updateCurrentUser() method. As a result, the user avatar gets updated.
- Swift
- Objective-C
updateCurrentUser() method.
Get user avatar
Now, other users can get your avatar by calling thedownloadFile(withUID:) method.
- Swift
- Objective-C