项目作者: micin-jp

项目描述 :
React Native module for SkyWay
高级语言: Objective-C
项目地址: git://github.com/micin-jp/react-native-skyway.git
创建时间: 2017-09-28T06:13:14Z
项目社区:https://github.com/micin-jp/react-native-skyway

开源协议:MIT License

下载


react-native-skyway

Installation

  1. npm install git+ssh://git@github.com/micin-jp/react-native-skyway.git#v0.1.1 --save
  2. react-native link react-native-skyway

iOS

Installing SkyWay Package

Install SkyWay package via CocoaPods.

  1. source 'https://github.com/CocoaPods/Specs.git'
  2. platform :ios, '9.0'
  3. target 'example' do
  4. pod 'SkyWay'
  5. inherit! :search_paths
  6. end

Android

Installing SkyWay package

Add SkyWay aar package manually. Download the SDK from SkyWay Developers site.

  1. Open Android Studio.
  2. Select Open Module Settings from the project view.
  3. Add the downloaded SDK(skyway.aar) as a new module.

Usage

  1. import React, { Component } from 'react';
  2. import { View } from 'react-native';
  3. import SkyWay from 'react-native-skyway';
  4. class AppComponent extends Component {
  5. componentDidMount() {
  6. this._connectPeer();
  7. }
  8. componentWillUnmount() {
  9. this._disposePeer();
  10. }
  11. _connectPeer() {
  12. const peerId = 'PEER_ID_1';
  13. const targetPeerId = 'PEER_ID_2';
  14. const options = {
  15. key: 'YOUR_API_KEY',
  16. domain: 'YOUR_DOMAIN',
  17. };
  18. const peer = new SkyWay.Peer(peerId, options)
  19. peer.connect();
  20. peer.addEventListener('peer-open', () => {
  21. peer.call(targetPeerId);
  22. });
  23. this.setState({ peer });
  24. }
  25. _disposePeer() {
  26. if (this.state.peer) {
  27. const peer = this.state.peer;
  28. peer.dispose();
  29. this.setState({peer: null});
  30. }
  31. }
  32. render() {
  33. return <View style={styles.container}>
  34. <SkyWay.LocalVideo style={styles.localVideo} peer={this.state.peer} ></SkyWay.LocalVideo>
  35. <SkyWay.RemoteVideo style={styles.remoteVideo} peer={this.state.peer} ></SkyWay.RemoteVideo>
  36. </View>
  37. }
  38. }
  39. const styles = StyleSheet.create({
  40. ...
  41. });

Authorizing Device Access

You should checking device permissions(camera, microphone) before starting video call.

Use react-native-permissions

Audio Management, Keeping Screen On

Use react-native-incall-manager.