Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to use react-native-webrtc in the constructor for simple peer

import wrtc from 'react-native-webrtc';

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

the error I'm getting is

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

like image 893
Walter Shub Avatar asked Sep 21 '20 17:09

Walter Shub


People also ask

Can I use Webrtc in react-native?

WebRTC is a powerful technology, and using react-native-webrtc we can build React Native applications with the same APIs available on browsers.

Can I use PeerJS in react-native?

react-native-webrtc has brought WebRTC to React Native. PeerJS is a simple API to work with WebRTC in the Browser. I made it so that PeerJS works with react-native-webrtc in a React Native application.

Does Webrtc support Expo?

currently this can be achieved using react-native-webrtc but expo does not support this package.


1 Answers

you have to import it like this


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
  },
});
like image 61
Walter Shub Avatar answered Oct 01 '22 13:10

Walter Shub