How to get started with QuickBlox React Native SDK
React Native makes use of native Objective-C/Swift and Java/Kotlin ingredients. They help native-like UI and boost performance in intensive operations. Yet, you can’t reuse native modules across different platforms.
We have recently announced the release of the Quickblox React Native SDK. Today we have prepared a step-by-step guide on building a messenger app with it. You are welcome to download Quickblox React Native SDK. It is in beta now, and we are ready to hear the feedback and improve our SDK according to your proposals.
Why do you need QuickBlox React Native SDK?
QuickBlox React Native SDK offers you all you need to build a chat messaging app. Our toolkit contains helpful methods for implementing the following functionality:
- Authentication. Upon the user logins to the application, the application starts a secure session. The token is valid for 2 hours after the last API request and is automatically renewed.
- Users. SDK has all the necessary toolset for secure storing, managing and updating the user information.
- Chat. For our messaging API, we use the XMPP protocol. Using the toolkit, you can manage the connection to chat server and managing 1-1 and group dialogs.
- Content. This module allows to store attachments and manage the content.
- Push Notifications. Push messages help you to keep in touch with the users who are not currently online. Using QuickBlox React Native SDK you can integrate push messaging into your Android or iOS app.
- Custom Objects. The Custom Objects module provides all you need to manage and update your records.
How to create a React Native app using QuickBlox SDK?
To create a new React Native chat messaging app with QuickBlox SDK from scratch follow these steps:
- Install Node.js
- Install React Native
- If you’re on MacOS – install CocoaPods
react-native init AwesomeChatAppto create a new project
- Navigate to created project and install JS dependencies with
- Add QuickBlox SDK to dependencies with
npm install quickblox-react-native-sdk --save
- If you’re on MacOS – install Pods: enter ios folder and run
You’re done with dependencies!
Launching the app
Now you can start the app with
react-native run-android or
But the application created is not really a chat messenger yet, right? So now you should create some UI for messages and then use our SDK to make it alive!
To make SDK work you should use your QuickBlox application account. To create a QuickBlox application, follow the steps below:
- Register a new account at https://admin.quickblox.com/signup. Type in your email and password to sign in. You can also sign in with your Google or Github accounts.
- Create the application clicking New app button.
- Configure the application. Type in the information about your organization into corresponding fields and click the Add button.
- Go to the screen with credentials. Locate Credentials groupbox and copy your Application ID, Authorization Key, Authorization Secret and Account Key. These data needed to run your application on QuickBlox server.
Now, it’s time to turn on the QuickBlox SDK:
Now you should sign in and connect to chat:
Once you signed in you can connect:
Great! Now since you’re connected to chat – it’s time to send a message to someone. Let’s create a new dialog:
In order to receive new messages we should tell SDK to send us events when there are new messages in chat:
But how will we handle new messages? We should probably assign an event handler:
So, now we have a dialog, we subscribed for new messages and created function to handle incoming messages. Let’s send our first message:
QuickBlox React Native SDK is here to speed up the process of messaging app development – from designing the prototype to final testing. Using our toolkit, you can integrate the messenger, voice, and video calling to your app, manage the files and objects. If you have any questions or suggestions, please submit a ticket to our support team.