Support
Quality
Security
License
Reuse
kandi has reviewed react-native-webrtc and discovered the below as its top functions. This is intended to give you an instant insight into react-native-webrtc implemented functionality, and help decide if they suit your requirements.
The WebRTC module for React Native
Usage
import {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
registerGlobals
} from 'react-native-webrtc';
RTCView
<RTCView streamURL={this.state.stream.toURL()}/>
React-Native [TypeError: null is not an object (evaluating 'WebRTCModule.enumerateDevices')]
(async () => {
await navigator.mediaDevices.getUserMedia({
audio: true,
video: {
width: 640,
height: 480,
frameRate: 30,
facingMode: (isFront ? "user" : "environment"),
deviceId: videoSourceId
}
});
let devices = await navigator.mediaDevices.enumerateDevices();
console.log(devices);
})();
Module not found for React Ntaive Webrtc while creating Android build
$ rm -rf node_modules/
$ npm i
$ npm i react-native-webrtc --save
$ cd android
$ ./gradlew clean
$ cd ..
$ react-native run-android
-----------------------
$ rm -rf node_modules/
$ npm i
$ npm i react-native-webrtc --save
$ cd android
$ ./gradlew clean
$ cd ..
$ react-native run-android
-----------------------
resolver: {
blacklistRE: /react-native-web/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
resolver: {
blacklistRE: /\react-native-web\b/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>-----------------------
resolver: {
blacklistRE: /react-native-web/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
resolver: {
blacklistRE: /\react-native-web\b/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>-----------------------
resolver: {
blacklistRE: /react-native-web/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
resolver: {
blacklistRE: /\react-native-web\b/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>-----------------------
resolver: {
blacklistRE: /react-native-web/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
resolver: {
blacklistRE: /\react-native-web\b/,
sourceExts: ["js", "json", "ts", "tsx", "android.js", "ios.js"]
}
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Disable native library for some Android version in React Native
import {Platform} from 'react-native'
[...]
if(Platform.OS == 'android' && Platform.Version >= 21){
//Do Something
}
[...]
-----------------------
android.enableDexingArtifactTransform.desugaring=false
Flipped view in RTCView for react-native
<RTCView streamURL={this.state.stream.toURL()} mirror={true} />
I am unable to initialise createOffer() after complete rendering of local stream?
if (isOffer){
pc.createOffer()
.then(function(desc) {
console.log("createOffer, desc);
pc.setLocalDescription(desc);
// something to do
}).
.catch(err => console.error(err));
}
setMicrophoneMute and setSpeakerPhoneOn not working in android audio call only (react-native)
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
React-native Access Device Camera? (Android Specifically)
import React from 'react';
import { View, Text, Alert } from 'react-native';
import { BarCodeScanner, Permissions } from 'expo';
class CameraForm extends React.Component {
state = {
hasCameraPermission: null
};
componentDidMount() {
this.permissionCheck();
}
permissionCheck = async () => {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({
hasCameraPermission: status === 'granted'
});
};
handleBarCodeScanRead = data => {
Alert.alert(
'Scan successful!',
JSON.stringify(data)
);
};
render() {
return (
<View style={styles.container}>
<Text>Scan your wallet code</Text>
{ this.state.hasCameraPermission === null ?
<Text>Requesting for camera permission</Text> :
this.state.hasCameraPermission === false ?
<Text>Camera permission is not granted</Text> :
<BarCodeScanner
onBarCodeRead={this.handleBarCodeScanRead}
style={{ height: 400, width: 400, marginTop: 20 }}
/>
}
</View>
);
}
}
const styles = {
container: {
flex: 1,
alignSelf: 'stretch',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'white'
}
};
export default CameraForm
-----------------------
Note:- I have implemented both the packages and both are working absolutely fine in android as well as ios, if u need any help u can ping me up.
How to propagate RTCPeerConnection changes to a React component with Mobx state management library
connection.onicecandidate = () => { /* update observable proprety here */ }
connection.oniceconnectionstatechange = () => { /* update observable proprety here */ }
connection.onsignalingstatechange = { /* update observable proprety here */ }
Redux Observable: How to return an action from a callback?
.mergeMap(action => {
return Observable.create(observer => {
WebRTC.setRemoteSdp(peerConnection, sdp, () => {
observer.next(myReducer.myAction());
observer.complete();
})
});
}
.mergeAll()
-----------------------
// bindCallback is a factory factory, it creates a function that
// when called with any arguments will return an Observable that
// wraps setRemoteSdp, handling the callback portion for you.
// I'm using setRemoteSdp.bind(WebRTC) because I don't know
// if setRemoteSdp requires its calling context to be WebRTC
// so it's "just in case". It might not be needed.
const setRemoteSdpObservable = Observable.bindCallback(WebRTC.setRemoteSdp.bind(WebRTC));
setRemoteSdpObservable(peerConnection, sdp)
.subscribe(d => console.log(d));
// observables are lazy, so defining this outside of our epic
// is totally cool--it only sets up the factory
const setRemoteSdpObservable = Observable.bindCallback(WebRTC.setRemoteSdp.bind(WebRTC));
function receivedSdp(action$, store) {
return action$.ofType(VideoStream.RECEIVED_SDP)
.mergeMap(action => {
const {peerConnection} = store.getState().videoStreams;
const {sdp} = action.payload;
return setRemoteSdpObservable(peerConnection)
.map(result => myReducer.myAction());
})
};
-----------------------
// bindCallback is a factory factory, it creates a function that
// when called with any arguments will return an Observable that
// wraps setRemoteSdp, handling the callback portion for you.
// I'm using setRemoteSdp.bind(WebRTC) because I don't know
// if setRemoteSdp requires its calling context to be WebRTC
// so it's "just in case". It might not be needed.
const setRemoteSdpObservable = Observable.bindCallback(WebRTC.setRemoteSdp.bind(WebRTC));
setRemoteSdpObservable(peerConnection, sdp)
.subscribe(d => console.log(d));
// observables are lazy, so defining this outside of our epic
// is totally cool--it only sets up the factory
const setRemoteSdpObservable = Observable.bindCallback(WebRTC.setRemoteSdp.bind(WebRTC));
function receivedSdp(action$, store) {
return action$.ofType(VideoStream.RECEIVED_SDP)
.mergeMap(action => {
const {peerConnection} = store.getState().videoStreams;
const {sdp} = action.payload;
return setRemoteSdpObservable(peerConnection)
.map(result => myReducer.myAction());
})
};
QUESTION
ERROR: Unknown named module "react-native-webrtc"
Asked 2021-May-09 at 21:04i'm seeing this error in my react-native app on android before launch. I haven't tested on iOS
this is a copy of my metro
BUNDLE ./index.js
WARN AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-async-storage/async-storage' instead of 'react-native'. See https://github.com/react-native-async-storage/async-storage
ERROR Error: Unknown named module: "react-native-webrtc"
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
My index.js
/**
* @format
*/
import {AppRegistry} from 'react-native';
import MainProject from './App';
import {name as appName} from './app.json';
import {Provider} from 'react-redux';
import {Provider as PaperProvider} from 'react-native-paper'
import store from './videocall/store'
import 'react-native-gesture-handler'
const AppRedux = () => (
<Provider {...{store}}>
<PaperProvider>
<MainProject />
</PaperProvider>
</Provider>
)
AppRegistry.registerComponent(appName, () => AppRedux);
Already tried the answer here , didn't work.
This is package.json
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-peerjs": "^1.0.4",
"react-native-webrtc": "1.89.1
ANSWER
Answered 2021-May-09 at 21:04Realized it only occurs on 1.89.1
downgrading to 1.84.1 worked for me
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit