Skip to content

Commit

Permalink
fix(cookies): init cookie manager after server url is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsChaceD authored Apr 17, 2023
1 parent 01b5b39 commit 0ee772f
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ public class CapacitorCookies extends Plugin {
@Override
public void load() {
this.bridge.getWebView().addJavascriptInterface(this, "CapacitorCookiesAndroidInterface");
if (isEnabled()) {
this.cookieManager = new CapacitorCookieManager(null, java.net.CookiePolicy.ACCEPT_ALL, this.bridge);
CookieHandler.setDefault(cookieManager);
}
super.load();
}

@JavascriptInterface
public boolean isEnabled() {
PluginConfig pluginConfig = getBridge().getConfig().getPluginConfiguration("CapacitorCookies");
return pluginConfig.getBoolean("enabled", false);
boolean isEnabled = pluginConfig.getBoolean("enabled", false);
if (isEnabled) {
this.cookieManager = new CapacitorCookieManager(null, java.net.CookiePolicy.ACCEPT_ALL, this.bridge);
CookieHandler.setDefault(cookieManager);
}
return isEnabled;
}

/**
Expand Down

0 comments on commit 0ee772f

Please sign in to comment.