Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

cbrevik/overrideWebview

Repository files navigation

Important files

Javascript implementation:

Usage from 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 shouldOverrideUrlLoading which lets me hook into URL navigations. Dispatches onSomethingHappened event if URL contains a certain string.
  • 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 shouldStartLoadWithRequest to hook into URL navigation. Dispatches onSomethingHappened event if URL contains a certain string.
  • RCTCustomWebViewManager.h
    • Header-file for view manager
  • RCTCustomWebViewManager.m
    • This is basically a copy-paste of RN's RCTWebViewManager. The only differences (noted in the file comments) is:
      1. Imports at the top
      2. The WebView returned (have to use the custom RCTCustomWebView of course)
      3. We also have to export the onSomethingHappened view property
  • RCTWebView+Custom.h
    • Adding a category to RCTWebView so we can expose (& call) shouldStartLoadWithRequest from (the child-cass) RCTCustomWebView. Not really important to this example, but good to note.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published