React Native Sample

Requirement

Qiscus Chat SDK supports developers who want to use React Native. You can use it seamlessly without any native bridging. To do so, you need to first install the Javascript chat SDK. You can do that by going to your app project and type the command bellow:

Bash
Copy

You can use other chat SDK features by following Javascript chat SDK docs

Try sample app

You can download the sample directly from our github repository, or if you already have git installed, you can just clone it, for example:

Bash
Copy

After cloning is completed, you will need React Native Command Line to run the sample app. In the example below, we use react-native-cli from nodejs package manager to serve sample app locally.

Bash
Copy

If you want your sample app running with your own App ID, you can change it inside the index.js which is located at app/qiscus/index.js. You can see the reference by clicking this link.

Setup Notification

The following steps on the assumption that you have already registered in Qiscus chat SDK.

Step 1: Install React Native Firebase Library

We recommend to use react-native-firebase library, this library is easy to setup FCM (Firebase Cloud Message). To setup, you need to do:

1) Go to Installation menu to initial setup,

2) Then you can install for specific platform:

3) Install Firebase Cloud Messaging dependency for specific platform:

4) Install RNFirebase Notification package for specific platform:

Step 2: Register FCM Server Key to Qiscus Chat SDK

You can follow this steps to register:

1) Go to this link to retrieve the FCM server key

2) Then go to this link to register your FCM server key to Qiscus chat SDK

Step 3: Register FCM Token to Qiscus Chat SDK

You need to make sure every time open the app, the FCM token need to be registered in Qiscus chat SDK server. Once the device token has been registered, the target user will receive the notification.

Javascript
Copy

Before calling registerDeviceToken() please make sure user already login in Qiscus

Step 4: Handling Incoming Message from Push Notification

You can handle receiving message by following this link, also for the notifications you can follow this steps instructions. This below sample code to handle incoming the notification:

Javascript
Copy

Required channel ID to display notifications in Android 8.0 (API level 26) and higher

Step 5: Handle Push Notification Event

You can handle notification event for example when open the notification, by following this link. This below code an example when redirect to particular chat room:

Javascript
Copy

If you still having trouble to setup push notification, you can reach out to our support team so we can help you!

Remove Notification

Once you logout or do not want to receive the push notification, you can remove the FCM token in Qiscus chat SDK by following code:

Javascript
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard