react-native-webview-rtc
this is customization library of react-native-webview-android.
Getting started
$ npm install react-native-webview-rtc --save
Mostly automatic installation
$ react-native link react-native-webview-rtc
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.webviewrtc.RNWebviewPackage;
to the imports at the top of the file - Add
new RNWebviewPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-webview-rtc' project(':react-native-webview-rtc').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-webview-rtc')
Sample Android Manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Usage
const WebViewAndroid = ; var SITE_URL = 'https://react-native-webrtc.herokuapp.com';var URL_DOMAIN = 'react-native-webrtc.herokuapp.com'; // inside react class{ superprops; thisstate = url: SITE_URL status: 'No Page Loaded' backButtonEnabled: false forwardButtonEnabled: false loading: true messageFromWebView: null } { // you can use this callback to control web view thisrefswebViewAndroidSample;} { thisrefswebViewAndroidSample;} { thisrefswebViewAndroidSample;} { // stops the current load thisrefswebViewAndroidSample;} { // posts a message to web view thisrefswebViewAndroidSample;} { // evaluates javascript directly on the webview instance thisrefswebViewAndroidSample;} { // executes JavaScript immediately in web view thisrefswebViewAndroidSample;} { console; // currently only url & navigationState are returned console; console; if eventurl return true; else return false; } { console; console; this;} { console; this;} { return ` $(document).ready(function() { $('a').click(function(event) { if ($(this).attr('href')) { var href = $(this).attr('href'); window.webView.postMessage('Link tapped: ' + href); } }) }) `} { return <WebViewAndroid ref="webViewAndroidSample" javaScriptEnabled=true javaScriptEnabledAndroid=true geolocationEnabled=false builtInZoomControls=false mediaPlayUserGesture=false injectedJavaScript=this onShouldStartLoadWithRequest=thisonShouldStartLoadWithRequest onNavigationStateChange=thisonNavigationStateChange onMessage=thisonMessage url=SITE_URL style=stylescontainerWebView /> ;} const styles = StyleSheet;
or see App.js
file in the library