react-native-custom-android-webview
v1.0.5
Published
Fork of the react-native webview that adds a couple new functions: 1. Ability to pass in an array of hostnames to open in a custom chrome tab 2. Ability to download PDFs / ZIPs / etc. automatically
Downloads
41
Readme
react-native-custom-android-webview
Fork of the react-native webview that adds a couple new functions:
- Ability to pass in an array of hostnames to open in a custom chrome tab
- Ability to download PDFs / ZIPs / etc. automatically
Note: Android only Supports all the same props as the default react native webview
Additional Props
In addition to usual React Native WebView props:
| Props | Type | Notes & Example |
|----------------|-----------------|---------------------------------------------------------------|
| openInternally | Array[string]
| ['google.com', 'facebook.com', 'app.facebook.com']
|
| toolbarColour | String
| Hex code value for the toolbarColour on the Chrome custom tab |
Manual installation
Step 1: Install npm package
npm install react-native-custom-android-webview
Step 2: Setup Android Project
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.ovoenergy.customwebview.CustomWebViewPackage;
to the imports at the top of the file - Add
new CustomWebViewPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-custom-android-webview'
project(':react-native-custom-android-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-custom-android-webview/android')
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
compile project(':react-native-custom-android-webview')
```
Usage
import CustomWebView from 'react-native-custom-android-webview';
<CustomWebView
...standardWebViewProps
openInternally={['google.com', 'facebook.com', 'app.facebook.com']}
/>;
Note: The openInternally list should be based on host, not domain
License
This project is licensed under the MIT License.