native-rtc
v0.1.0
Published
Native WebRTC module for React Native / Expo
Maintainers
Readme
native-rtc
Native WebRTC module for React Native (Expo). Built on top of libwebrtc — no JavaScript WebRTC polyfills.
Installation
npx expo install native-rtcSetup
Add to your app.json:
{
"expo": {
"plugins": ["native-rtc"]
}
}Add mic permission to your AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />Request runtime permission before calling init():
import { Audio } from 'expo-av';
await Audio.requestPermissionsAsync();Usage
import rtcClient from 'native-rtc';
// Caller side
await rtcClient.init();
await rtcClient.createPeerConnection();
await rtcClient.startAudio();
const offer = await rtcClient.createOffer();
// Send offer to remote peer via your signaling server
// then when you receive an answer:
await rtcClient.setRemoteDescription(answerSdp);
// Handle ICE candidates
const sub = rtcClient.onIceCandidate((data) => {
// send data to remote peer via signaling
});
// Cleanup
sub.remove();
await rtcClient.dispose();