react-native-quickomcallingsdk-googlewebrtc

0.1.1 • Public • Published

#React Native QuickOM Calling SDK

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

Full Documentation

Main Functions Supported

  1. Voice call
  2. Message
  3. CallKit

Requirements

  • npm version 6.9.0
  • react-native version >= 0.60

Install

1. Install the library

npm i react-native-quickomcallingsdk-googlewebrtc

2. Link

react-native link react-native-quickomcallingsdk-googlewebrtc

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

3. Configure your project

Android

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

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 / Capabilities, section Push Notifications (Enable VoIP 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

1. File -> New -> File
2. Select Swift File
3. Confirm Create Bridging Header

Go to Settings / Build Settings, set Always Embed Swift Standard Libraries = YES

Optional, if you can use feature Callkit:

  • Add the following in file "AppDelegate.h" to your project
#import <PushKit/PushKit.h>

@property (nonatomic, retain) PKPushRegistry *pushRegistry;
  • Add the following in file "AppDelegate.m" to your project
#import <PushKit/PushKit.h>
#import "CallCenter.h"

- (BOOL)application:(UIApplication *)application {

	//register for voip notifications
	self.pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
	[self.pushRegistry setDelegate:self];
	[self.pushRegistry setDesiredPushTypes:[NSSet setWithObject:PKPushTypeVoIP]];

	return YES;
}

#pragma mark - VoIP push methods

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
  [CallCenter pushRegistry:registry didUpdatePushCredentials:credentials forType:type];
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
  [CallCenter pushRegistry:registry didReceiveIncomingPushWithPayload:payload forType:type];
}

- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type {
  [CallCenter pushRegistry:registry didInvalidatePushTokenForType:type];
}

Usage

Import library

import QuickOMCallingSDK from 'react-native-quickomcallingsdk-googlewebrtc';

init sdk

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

  let quickOMCallingSDK = new QuickOMCallingSDK(apiKey);
  quickOMCallingSDK.init()
	.then(() => {
		// opened sdk
	});
}

Stop sdk

stop() {
  quickOMCallingSDK.stop()
    .then(() => {
      // closed sdk
    });
}

Listen delivered message

quickOMCallingSDK.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"}
});

Listen delivered calling

quickOMCallingSDK.on('calling', (data) => {
	// data => { identifier, isVideoCall, status }
	// or { duration, status }
	// {"identifier":"support1001@gmail.com","isVideoCall":"NO","status":"incoming"}
	// {"identifier":"support1001@gmail.com","isVideoCall":"YES","status":"connected"}
	// {"duration":"1.266337","status":"end"}
});

Listen delivered generate push content when caller after making call (require: enabled Callkit)

quickOMCallingSDK.on('generatePushContent', (data) => {
	// data => { data, identifier, type }
	// {"data": "eyJ0eXBlIjoiZHJvcCIsImRyb3BSZXF1ZXN0SWQiOiJDQUZDMDJCNS1GNDFCLTRCOTYtODNCMS05MUQxNTE3RjY3NjAiLCJyZXF1ZXN0SWQiOiIzMkQyQ0I0OS1EQkEwLTQ5MEQtODRCMy05OTg5NzBERkYxM0UifQ==", "identifier": "support1001@gmail.com", "type": "2"}
});

Submit the data to your server. Your server must put the data to field alert within field aps of push notification content as following format

	aps =     {
		alert = "<data>";
		badge = 1;
		sound = default;
	};

Request voice call

requestVoiceCall() {
	// identifier => an unique id to identify an user who will be connected with
  quickOMCallingSDK.requestVoiceCall(identifier)
	.then((res) => {
		// success
		// res => { identifier, isVideoCall }
  	// {"identifier":"support1001@gmail.com", "isVideoCall": "NO"}
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - Framework isn’t configured yet
		// 11 - Framework isn’t started yet
		// 100 - Can’t start calling
		// 101 - Callee account doesn’t exist
		// 102 - Callee is busy because currently callee is in another call
		// 103 - Callee denies the call
		// 104 - Caller canceled the call
		// 105 - The call is timeout because callee doesn’t pick up or deny the call
		// 106 - Call from caller is timeout
	});
}

End current call

endCall() {
  quickOMCallingSDK.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
	});
}

accept current call

acceptCall() {
  quickOMCallingSDK.acceptCall()
	.then(() => {
		// success
		// res => { identifier, isVideoCall }
		// {"identifier": "support1001@gmail.com", "isVideoCall": "YES"}
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - Framework isn’t configured yet
		// 11 - Framework isn’t started yet
		// 22 - Framework is configuring
	});
}

deny current call

denyCall() {
  quickOMCallingSDK.denyCall()
	.then(() => {
		// success
		// res => { duration }
		// {"duration":"0"}
	})
	.catch((err) => {
		// err => { code, description }
		// 10 - Framework isn’t configured yet
		// 11 - Framework isn’t started yet
		// 22 - Framework is configuring
	});
}

Set custom sound for outgoing and incoming call

// By default , these properties are set to null.
// If it’s is null, Beowulf default calling sound will be played

// Sound file’s type can be 'mp3' or 'wav' but 'mp3' is prefer than 'wav'
// Total duration of the sound file should be less than 30 seconds for best performance

setSoundOutgoingCall() {
	// path => Sound file’s type
  quickOMCallingSDK.setSoundOutgoingCall(path);
}

setSoundIncomingCall() {
	// path => Sound file’s type
  quickOMCallingSDK.setSoundIncomingCall(path);
}

Set Enable / Disable playing sound for outgoing and incoming call

// By default , these properties are set to false.
// If 'shouldPlaySoundForOutgoingCall' is true and 'customCallingSoundPathForOutgoingCall' has valid and non-null value, custom sound will be played.
// If 'customCallingSoundPathForOutgoingCall' is null or path doesn’t exist, Beowulf default sound will be played instead.
  
// If 'shouldPlaySoundForIncomingCall' is true and 'customCallingSoundPathForIncomingCall' has valid and non-null value, custom sound will be played.
// If 'customCallingSoundPathForIncomingCall' is null or path doesn’t exist, Beowulf default sound will be played instead.

setPlaySoundOutgoingCall() {
	// shouldPlay => true / false
	// Default is false
  quickOMCallingSDK.setPlaySoundOutgoingCall(shouldPlay); 
}

setPlaySoundIncomingCall() {
	// shouldPlay => true / false
	// Default is false
  quickOMCallingSDK.setPlaySoundIncomingCall(shouldPlay); 
}

Send text messsage

sendText() {
  // messContent => text sending
  // to => an unique id to identify an user on your platform. In this case, it’s an identifier of RECEIVER whom the message will be send to
  quickOMCallingSDK.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 => an unique id to identify an user on your platform. In this case, it’s an identifier of RECEIVER whom the message will be send to
  quickOMCallingSDK.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 => an unique id to identify an user on your platform. In this case, it’s an identifier of whom the Seen status will be notify to
  quickOMCallingSDK.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
	});
}

Enable callkit, availability: from iOS 10

setEnableCallKit() {
  // enable => enable / disable callkit
  // appName => callkit app name
	// include => includes the calls in recents
	// imageName => callkit app image name (Opitonal)
	// ringtoneName => callkit ringtone name (Opitonal)
	// {"enable": true, "appName": 'SDK-CMM', "include": true}
  quickOMCallingSDK.enableCallKit({ enable, appName, include, imageName, ringtoneName })
	.then(() => {
		// success
	})
	.catch((err) => {
		// err => { code, description }
		// 107 - Callkit isn’t supported 
	});
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    0
    • latest

Version History

Package Sidebar

Install

npm i react-native-quickomcallingsdk-googlewebrtc

Weekly Downloads

0

Version

0.1.1

License

ISC

Unpacked Size

73 MB

Total Files

204

Last publish

Collaborators

  • jackhuynh95