react-native-quickomsdk-webrtc
v0.0.2
Published
QuickOM SDK support for React Native apps.
Downloads
1
Maintainers
Readme
#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
- Request Voice call Support
- Request Chat Support
Requirements
- npm version 6.9.0
- react-native version >= 0.60
Install
1. Install the library
npm i react-native-quickomsdk-webrtc
2. Link
react-native link react-native-quickomsdk-webrtc
// Note For iOS using cocoapods, run:
cd ios && pod install
3. Configure your project
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
|Property|Description| |----------|------------| | Voice over IP |Call via network| | Audio, AirPlay, and Picture in Picture |Support call via network feature| | Background fetch |Support call via network feature| | Remote notifications |Support Remote push notification|
Go to Settings / Build Settings, section Build Options, set Enable Bitcode = No
Add the following 'Podfile' to your project
use_frameworks!
Add a new Swift file and a Brigde header
- File -> New -> File
- Select Swift File
- Confirm Create Bridging Header
Go to Settings / Build Settings, set Always Embed Swift Standard Libraries = YES
Usage
Import library
import QuickOMSDK from 'react-native-quickomsdk-webrtc';
init sdk
init() {
// register apiKey from beowulfchain
// apiKey = UEMrUzJSc1RXVmR6aGpmb2liNUJoVGNOYjdhb0tmYW9HUWZqY2VwaFhLWjNqS2crb0UrVnF3Wkw3T01zVVN2TA==
let quickOMSDK = new QuickOMSDK(apiKey);
quickOMSDK.init()
.then(() => {
// opened sdk
});
}
Stop sdk
stop() {
quickOMSDK.stop()
.then(() => {
// closed sdk
});
}
Listen delivered message
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":"[email protected]","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":"[email protected]","date":1573208910342.4329}
// or {"status":"seen","msgId":"19921570534911738_1573123096.548","from":"[email protected]"}
});
Listen delivered calling
quickOMCallingSDK.on('calling', (data) => {
// data => { identifier, isVideoCall, status }
// or { duration, status }
// {"identifier":"[email protected]","isVideoCall":false,"status":"connected"}
// {"duration":"1.266337","status":"end"}
});
Request voice call
requestVoiceCall() {
// displayName => display name
// alias => alias qrcode
quickOMSDK.requestVoiceCall({ displayName: 'Jack', alias: '99261577263494399' })
.then((res) => {
// success
// res => { identifier }
// {"identifier":"[email protected]"}
})
.catch((err) => {
// err => { code, description }
// 10 - Framework isn’t configured yet
// 11 - Framework isn’t started yet
// 26 - Group doesn’t exist
// 100 - Can’t start calling
// 326 - No supporter is available now
});
}
End current call
endCall() {
quickOMSDK.endCall()
.then((res) => {
// success
// res => { duration }
// {"duration":"1.266337"}
})
.catch((err) => {
// err => { code, description }
// 10 - Framework isn’t configured yet
// 11 - Framework isn’t started yet
});
}
Request chat
requestChat() {
// displayName => display name
// alias => alias qrcode
quickOMSDK.requestChat({ displayName: 'Jack', alias: '99261577263494399' })
.then((res) => {
// success
// res => { identifier }
// {"identifier":"[email protected]"}
})
.catch((err) => {
// err => { code, description }
// 10 - Framework isn’t configured yet
// 11 - Framework isn’t started yet
// 26 - Group doesn’t exist
// 100 - Can’t start calling
// 326 - No supporter is available now
});
}
Send text messsage
sendText() {
// messContent => text sending
// to => identifier from the response of request voice call / chat
quickOMSDK.sendText({ messContent, to })
.then((res) => {
// success
// res => msgId
})
.catch((err) => {
// err => { code, description }
// 10 - Framework isn’t configured yet
// 11 - Framework isn’t started yet
// 23 - Enterprise is not authorized
// 202 - Unable to send message
// 203 - Receiver account does not exist
});
}
Send image
sendImage() {
// source => base64 image or linkUrl
// to => identifier from the response of request voice call / chat
quickOMSDK.sendImage({ source, to })
.then((res) => {
// success
// res => msgId
})
.catch((err) => {
// err => { code, description }
// 10 - Framework isn’t configured yet
// 11 - Framework isn’t started yet
// 23 - Enterprise is not authorized
// 202 - Unable to send message
// 203 - Receiver account does not exist
});
}
Send message seen
sendSeen() {
// msgId => msgId from listen delivered message
// to => identifier from the response of request voice call / chat
quickOMSDK.sendSeen({ msgId, to })
.then(() => {
// success
})
.catch((err) => {
// err => { code, description }
// 10 - Framework isn’t configured yet
// 11 - Framework isn’t started yet
// 204 - Unable to send status
});
}