🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

react-native-offline-cache-webview

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-offline-cache-webview

Offline cache enabled WebView

latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
113
21.51%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-offline-cache-webview

Features

Offline cache enabled WebView, works for Android and iOS.

iOSAndroid

Install

npm i react-native-offline-cache-webview --save
react-native link react-native-offline-cache-webview

Usage

import OfflineCacheWebView from 'react-native-offline-cache-webview';
export default class webview extends Component {
    render() {
        return (
            <OfflineCacheWebView
                style={styles.webview}
                source={{uri: 'http://facebook.github.io/react-native/blog/2018/06/14/state-of-react-native-2018'}}
            />
        );
    }
}

Example

  • Check it here

How does this work?

For iOS, the offline cache is implemented with RNCachingURLProtocol

RNCachingURLProtocol is a simple shim for the HTTP protocol (that’s not nearly as scary as it sounds). Anytime a URL is downloaded, the response is cached to disk. Anytime a URL is requested, if we’re online then things proceed normally. If we’re offline, then we retrieve the cached version.

For Android, it's provided by CacheWebView

CacheWebView is a custom implement of Android WebView resource interceptor. It beyond system WebView cache space limit, let cache config more simple ,fast and flexible. Visit website by offline.

This library is built on top of react-native-advanced-webview, the architecture leveraged for customizing React Naitve WebView

TODO

  • offlineCacheMode property to control on/off for cache usage
  • prefetch method for caching url by advance
  • clearCache method

References

Keywords

react-component

FAQs

Package last updated on 04 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts