nativescript-sinch
by triniwiz | v1.1.5
NativeScript plugin to use sinch
npm i --save nativescript-sinch

#NativeScript-Sinch ##WIP

##Install Note : If the android platform is not added before installing this plugin the installation will fail.

tns platform add android 
tns plugin add nativescript-sinch
var sinch = require('nativescript-sinch');

//or

import {Sinch} from 'nativescript-sinch';

Initialize

var sinchClient = new sinch.Sinch("appKey", "appSecret", "host", "username");

//or

let sinchClient = new Sinch("appKey", "appSecret", "host", "username");

Specify the client capabilities

 sinchClient.setSupportMessaging(true);
sinchClient.setSupportCalling(true);
sinchClient.setSupportActiveConnectionInBackground(true);
sinchClient.setSupportPushNotifications(true);

Start the client

sinchClient.start();

Stop listening for incoming events (calls or messages).

sinchClient.stopListeningOnActiveConnection();

Stop the client when the calling or messaging functionality is no longer needed.

sinchClient.stop();

Get CallClient

sinchClient.getCallClient();

e.g

var callClient = sinchClient.getCallClient();
callClient.callUser("triniwiz");

Methods

addCallClientListener(callClientListener:()=>void)
callConference(conferenceId:string)
callConference(conferenceId,headers:string[])
callPhoneNumber(phoneNumber:string)
callPhoneNumber(phoneNumber:string,headers:string[])
callSip(sipIdentity:string)
callSip(sipIdentity:string,headers:string[])
callUser(toUserId:string)
callUser(toUserId:string,headers:string[])
callUserVideo(toUserId:string)
callUserVideo(toUserId:string,headers:string[])
getCall(callId:string)
removeCallClientListener(callClientListener:()=>void)
setRespectNativeCalls(respectNativeCalls:boolean)

Get MessageClient

sinchClient.getMessageClient();

e.g

var messageClient = sinchClient.getCallClient();

Methods

var message = sinchClient.writableMessage();
var message = sinchClient.writableMessage(["triniwiz","brad","jen","peter"],"Hi");
var message = sinchClient.writableMessage("triniwiz","Sup");
messageClient.send(message);
addMessageClientListener(callback:()=>void);
removeMessageClientListener(callback:()=>void);
send(message:WriteableMessage);

Get VideoController

 sinchClient.getVideoController()

e.g

var videoController = sinchClient.getVideoController();
videoController.getCaptureDevicePosition()
videoController.getLocalView()
videoController.getRemoteView()
videoController.setBorderColor(float r, float g, float b)
videoController.setCaptureDevicePosition(int facing)
videoController.setResizeBehaviour(VideoScalingType type)
videoController.toggleCaptureDevicePosition()

Get AudioController

  sinchClient.getAudioController()

e.g

var audioController = sinchClient.getAudioController();

audioController.mute();
audioController.unmute();
audioController.enableSpeaker();
audioController.disableSpeaker();