npm.io
0.0.8 • Published 7 years ago

mobile-rn-webview

Licence
MIT
Version
0.0.8
Deps
0
Size
39 kB
Vulns
0
Weekly
0

mobile-rn-webview

WebView with onShouldStartLoadWithRequest method supported on Android platform

Getting started

$ npm install mobile-rn-webview --save

Mostly automatic installation

$ react-native link mobile-rn-webview

Manual installation
iOS
Android
  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNMobileRnWebviewPackage; to the imports at the top of the file
  • Add new RNMobileRnWebviewPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':mobile-rn-webview'
    project(':mobile-rn-webview').projectDir = new File(rootProject.projectDir,     '../node_modules/mobile-rn-webview/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
    compile project(':mobile-rn-webview')

Usage

import WebView from 'mobile-rn-webview';

onShouldStartLoadWithRequest(event) {
    const { url } = event;
    ...
}

...

<WebView style={{flex: 1}}
        source={{html: html}}
        onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
/>
...

Keywords