react-native-giga-web-view
v2.0.0
Published
## Getting started
Downloads
11
Readme
react-native-giga-web-view
Getting started
$ npm install react-native-giga-web-view --save
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
(No need if your react-native version can automatically link)
- Add
import com.reactlibrary.RNGigaWebViewPackage;
to the imports at the top of the file - Add
new RNGigaWebViewPackage()
to the list returned by thegetPackages()
method
Append the following lines to
android/settings.gradle
: (No need if your react-native version can automatically link)include ':react-native-giga-web-view' project(':react-native-giga-web-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-giga-web-view/android')
Insert the following lines inside
android/app/build.gradle
:android { ... aaptOptions { noCompress 'pak', 'dat', 'bin' additionalParameters "--extra-packages", "com.gigasource.webview3:org.chromium.content_shell_apk:org.chromium.ui:org.chromium.content_shell:org.chromium.content:org.chromium.media" } packagingOptions { exclude("META-INF/*.version") exclude("play-services-base.properties") exclude("play-services-tasks.properties") exclude("play-services-basement.properties") exclude("play-services-places-placereport.properties") exclude("play-services-location.properties") } ... } // No need to add if your version is automatically link dependencies { ... compile project(':react-native-giga-web-view') ... }
Insert the following lines inside method "onCreate()" of "MainApplication.java":
if (Build.VERSION.SDK_INT >= 28) { if (getPackageName().equals(getProcessName())) { SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } } else { @SuppressLint("PrivateApi") Class<?> activityThread = null; try { activityThread = Class.forName("android.app.ActivityThread"); // Before API 18, the method was incorrectly named "currentPackageName", but it still returned the process name // See https://github.com/aosp-mirror/platform_frameworks_base/commit/b57a50bd16ce25db441da5c1b63d48721bb90687 String methodName = Build.VERSION.SDK_INT >= 18 ? "currentProcessName" : "currentPackageName"; Method getProcessName = activityThread.getDeclaredMethod(methodName); String processName = (String) getProcessName.invoke(null); if (processName.equals(getPackageName())) { SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }
Usage
import GigaWebView from 'react-native-giga-web-view';
...
<GigaWebView style={{width: '100%', height: '100%'}} source={{uri: "https://google.com"}}/>
...