如何在 react-native-webrtc 中使用 simple-peer

How to use simple-peer with react-native-webrtc

我正在尝试在简单对等点的构造函数中使用 react-native-webrtc

import wrtc from 'react-native-webrtc';

const peer = new SimplePeer({initiator: true, wrtc: wrtc});

我遇到的错误是

ExceptionsManager.js:179 Error: No WebRTC support: Not a supported browser

你必须像这样导入它


import {
  RTCPeerConnection,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView,
  MediaStream,
  MediaStreamTrack,
  mediaDevices,
  registerGlobals
} from 'react-native-webrtc';

const peer = new SimplePeer(
{initiator: true, 
 wrtc: { 
  RTCPeerConnection,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView,
  MediaStream,
  MediaStreamTrack,
  mediaDevices,
  registerGlobals
  },
});