Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
localStorageEnabled option on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
rasom committed Dec 23, 2016
1 parent 8286767 commit 99e7e9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ public void setInjectedOnStartLoadingJavaScript(WebView view, @Nullable String i
((ReactWebView) view).setInjectedOnStartLoadingJavaScript(injectedJavaScript);
}

@ReactProp(name = "localStorageEnabled")
public void setLocalStorageEnabled(WebView view, boolean enabled) {
if (enabled) {
view.getSettings().setDomStorageEnabled(true);
view.getSettings().setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
view.getSettings().setDatabasePath("/data/data/" + view.getContext().getPackageName() + "/databases/");
}
}
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
// Do not register default touch emitter and let WebView implementation handle touches
Expand Down
2 changes: 2 additions & 0 deletions webview-bridge/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ var WebViewBridge = React.createClass({
onBridgeMessage: PropTypes.func,

injectedOnStartLoadingJavaScript: PropTypes.string,

localStorageEnabled: PropTypes.bool,
},

getInitialState: function() {
Expand Down

0 comments on commit 99e7e9c

Please sign in to comment.