nativescript-sinch
用于使用 sinch 的 NativeScript 插件
npm i --save nativescript-sinch

#NativeScript-Sinch ##WIP

##安装 注意:如果安装此插件之前没有添加 android 平台,则安装将失败。

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

//or

import {Sinch} from 'nativescript-sinch';

初始化

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

//or

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

指定客户端功能

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

启动客户端

sinchClient.start();

停止监听传入的事件(电话或消息)。

sinchClient.stopListeningOnActiveConnection();

当不再需要电话或消息功能时停止客户端。

sinchClient.stop();

获取 CallClient

sinchClient.getCallClient();

例如

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

方法

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)

获取 MessageClient

sinchClient.getMessageClient();

例如

var messageClient = sinchClient.getCallClient();

方法

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);

获取 VideoController

 sinchClient.getVideoController()

例如

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()

获取 AudioController

  sinchClient.getAudioController()

例如

var audioController = sinchClient.getAudioController();

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