#React Native QuickOM SDK

React Native QuickOM SDK is library javascript client for Beowulf Quickom.

## Full Documentation

- The api documentation can be found in the official beowulf developers portal: https://beowulfchain.com/developer-guide/quickom

## Main Functions Supported

1. Request Voice Call to Group
2. Request Chat to Group

## Requirements

- npm version 6.9.0

## Install

### 1. Install the library

```bash
npm i react-native-quickomsdk
```

### 2. Link

<!-- // React Native support <= 6.05 -->

```bash
react-native link react-native-quickomsdk

// Note For iOS using cocoapods, run:
cd ios && pod install
```

### 3. Configure your project

#### Android

```bash
Deployment target: minimum android api 21
```

#### IOS

Add these keys to Info.plist

| Key                          | Description                                           |
| ---------------------------- | ----------------------------------------------------- |
| NSCameraUsageDescription     | Request application’s permission to access Camera     |
| NSMicrophoneUsageDescription | Request application’s permission to access Microphone |

\
Go to Settings / Capabilities, section Background Modes, enable these capabilities

```bash
Voice over IP
Background fetch
```

Go to Settings / Build Settings, section Build Options, set Enable Bitcode = No

## Usage

Import library

```bash
import QuickOMSDK from 'react-native-quickomsdk';
```

init sdk

```bash
init() {
  // register apiKey from beowulfchain
  // apiKey = UEMrUzJSc1RXVmR6aGpmb2liNUJoVGNOYjdhb0tmYW9HUWZqY2VwaFhLWjNqS2crb0UrVnF3Wkw3T01zVVN2TA==

  let quickOMSDK = new QuickOMSDK(apiKey);
  quickOMSDK.init()
	.then(() => {
		// opened sdk
	});
}
```

Stop sdk

```bash
stop() {
  quickOMSDK.stop()
    .then(() => {
      // closed sdk
    });
}
```

Listen delivered message

```bash
quickOMSDK.on('message', (data) => {
  // data => { isImage, content, msgId, convId, from, date (timestamp) }
  // or { status, msgId, from }
  // {"isImage":false,"content":"Gy","msgId":"93181562051293759_1573123121.940","convId":"c604cfd5-3e42-4bcc-ab7d-bea804c7b0e1","from":"support1001@gmail.com","date":1573123122319.268}
  // {"isImage":true,"content":"https://kryptono-ex.s3.amazonaws.com/chat_photo_1573205308439.png","msgId":"93181562051293759_1573205306.793","convId":"65961570683864472_1573208896.502451","from":"support1001@gmail.com","date":1573208910342.4329}
  // or {"status":"seen","msgId":"19921570534911738_1573123096.548","from":"support1001@gmail.com"}
});
```

Request voice call

```bash
requestVoiceCall() {
	// displayName => display name
	// groupName => group calling
  quickOMSDK.requestVoiceCall({ displayName: 'Jack', groupName: 'CS1' })
	.then((res) => {
		// success
		// res => { identifier }
  		// {"identifier":"support1001@gmail.com"}
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - This error usually occurs in case the method + configureWithApiKey: isn’t called yet
		// 11 - This error usually occurs in case one of the start-framework method isn’t called yet or it is NOT started successfully
		// 26 - This error occurs because group doesn’t exist. The name of group should be exactly correct and case sensitive
		// 100 - Unable to make call due to internal problem
		// 326 - No supporter is available at the moment => call function endVoiceCall()
	});
}
```

End voice call

```bash
endVoiceCall() {
  quickOMSDK.endVoiceCall()
	.then(() => {
		// success
	});
}
```

Request chat

```bash
requestChat() {
  // displayName => display name
  // groupName => group chatting
  quickOMSDK.requestChat({ displayName: 'Jack', groupName: 'CS1' })
	.then((res) => {
		// success
		// res => { identifier }
  		// {"identifier":"support1001@gmail.com"}
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - This error usually occurs in case the method + configureWithApiKey: isn’t called yet
		// 11 - This error usually occurs in case one of the start-framework method isn’t called yet or it is NOT started successfully
		// 26 - This error occurs because group doesn’t exist. The name of group should be exactly correct and case sensitive
		// 100 - Unable to make call due to internal problem
		// 326 - No supporter is available at the moment
	});
}
```

Send text messsage

```bash
sendText() {
  // messContent => text sending
  // to => identifier from listen supporter
  quickOMSDK.sendText({ messContent, to })
	.then((res) => {
		// success
		// res => msgId
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - This error usually occurs in case the method + configureWithApiKey: isn’t called yet
		// 11 - This error usually occurs in case one of the start-framework method isn’t called yet or it is NOT started successfully
		// 23 - Enterprise account does not exist or it doesn’t have permission to use this framework. Contact us to find out the reason
		// 202 - the message is unable to send now
		// 203 - receiver account does not exist on Beowulf system. Account must start this framework to register to Beowulf system if not exist
	});
}
```

Send image

```bash
sendImage() {
  // source => base64 image or linkUrl
  // to => identifier from listen supporter
  quickOMSDK.sendImage({ source, to })
	.then((res) => {
		// success
		// res => msgId
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - This error usually occurs in case the method + configureWithApiKey: isn’t called yet
		// 11 - This error usually occurs in case one of the start-framework method isn’t called yet or it is NOT started successfully
		// 23 - Enterprise account does not exist or it doesn’t have permission to use this framework. Contact us to find out the reason
		// 202 - the message is unable to send now
		// 203 - receiver account does not exist on Beowulf system. Account must start this framework to register to Beowulf system if not exist
	});
}
```

Send message seen

```bash
sendSeen() {
  // msgId => msgId from listen delivered message
  // to => identifier from listen supporter
  quickOMSDK.sendSeen({ msgId, to })
	.then(() => {
		// success
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - This error usually occurs in case the method + configureWithApiKey: isn’t called yet
		// 11 - This error usually occurs in case one of the start-framework method isn’t called yet or it is NOT started successfully
		// 204 - Can’t send message status
	});
}
```
