7

我正在尝试在构造函数中使用 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

4

1 回答 1

1

你必须像这样导入它


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
  },
});
于 2021-02-23T20:53:07.747 回答