NativeScript WebRTC
Uses this for Android and this for iOS.
Installation
tns plugin add nativescript-webrtc-plugin
Android
Add the following to your app.gradle located in app/App_Resources
android {....compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 }}
How to make a call
;WebRTC; // <= Try calling this in you app.js or app.ts or main.ts
IMPORTANT: Make sure you include xmlns:webrtc="nativescript-webrtc-plugin" on the Page element
Using Angular ?
Import the WebRTCModule from nativescript-webrtc-plugin/angular and add it to the imports of your initial @NgModule, like shown here.
Vue
;; Vue;
Standard Api ✨ New ✨
This api is similar to the webrtc browser api -> example but with TNS
appended e.g TNSRTCPeerConnection
Basic Api
Caller
;; webrtc.on'webRTCClientDidReceiveRemoteVideoTrackStream', ; webrtc.on'webRTCClientStartCallWithSdp', ; webrtc.on'webRTCClientDidGenerateIceCandidate', ; // Before using getUserMedia verify the app has the permissions and if not try requesting them if !WebRTC.hasPermissions webrtc.connect;webrtc.addLocalStreamlocalStream;webrtc.makeOffer;
Callee
;; webrtc.on'webRTCClientStartCallWithSdp', ; webrtc.on'webRTCClientDidGenerateIceCandidate', ; // Before using getUserMedia verify the app has the permissions and if not try requesting them if !WebRTC.hasPermissions webrtc.connect;webrtc.addLocalStreamlocalStream;// sdp received from the signaling serverwebrtc.createAnswerForOfferReceived;
Using demo
Note the demo can be ran on a device w/o a camera but you will need to disable the video option here an here for core or here an here for angular also the app connects to remote stun server(s) so internet connection is needed.
-
Start demo-server by running
npm i && node app
-
Edit the socket-server.ts or environment.ts to point to your computer's local ip where the demo-server is running
-
Run the demo/demo-ng enter usernames on both device then tap on the username of the other device the demo will auto answer the call . 🙂
License
Apache License Version 2.0, January 2004