webview-native-config-example
webview-native-config-example copied to clipboard
Example for CustomWebView with nativeConfig
Important files
Javascript implementation:
- CustomWebView.js
Usage from JS:
- MyApp.js
Android implementation:
- CustomWebViewManager.java
- This file contains all the logic for the custom webview. In this case all I do is extend the ReactWebViewClient and override
shouldOverrideUrlLoadingwhich lets me hook into URL navigations. DispatchesonNavigationCompletedevent if URL is equals to thefinalUrlprop.
- This file contains all the logic for the custom webview. In this case all I do is extend the ReactWebViewClient and override
- CustomWebViewManagerPackager.java
- The packager-class, used in MainApplication to hook up the above ViewManager to the app.
iOS implementation:
- RCTCustomWebView.h
- Header-file for the webview
- RCTCustomWebView.m
- Same logic as Android. Overriding
shouldStartLoadWithRequestto hook into URL navigation. DispatchesonNavigationCompletedevent if URL is equals to thefinalUrlprop.
- Same logic as Android. Overriding
- RCTCustomWebViewManager.h
- Header-file for view manager
- RCTCustomWebViewManager.m
- Inherits from RN's RCTWebViewManager. Adds the
finalUrlprop and theonNavigationCompletedevent.
- Inherits from RN's RCTWebViewManager. Adds the
- RCTWebView+Custom.h
- Adding a category to
RCTWebViewso we can expose (& call)shouldStartLoadWithRequestfrom (the child-cass)RCTCustomWebView. Not really important to this example, but good to note.
- Adding a category to