1.0.5 • Published 7 years ago

react-native-custom-android-webview v1.0.5

Weekly downloads
18
License
MIT
Repository
github
Last release
7 years ago

react-native-custom-android-webview

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

Note: Android only Supports all the same props as the default react native webview

Additional Props

In addition to usual React Native WebView props:

PropsTypeNotes & Example
openInternallyArray[string]['google.com', 'facebook.com', 'app.facebook.com']
toolbarColourStringHex 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

  1. 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 the getPackages() method
  1. 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')
    		```
  2. 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.