Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InAppBrowser not load the page with cookies when I use the hardware back button #992

Open
3 tasks done
drhenchufesolar opened this issue Feb 6, 2023 · 0 comments
Open
3 tasks done

Comments

@drhenchufesolar
Copy link

drhenchufesolar commented Feb 6, 2023

Bug Report

I have an application in Ionic 6 and Angular 14 in which I use the InAppBrowser plugin to use a web application of my company and the plugin doesn't load the cache/cookie from web when I use the hardware back button.

Problem

The plugin works fine in general, the situation is that there is a cookie in the web application that is used for the filters of some lists that are in the web application. When a user filters and enters (for example) a specific client from a list and uses the hardware back button to go back to the list, the filter disappears. From the PC, when you go back the filter is maintained, which means that the cache is maintained.

When I use the DevTools (from Google Chrome: chrome://inspect) to check the Ionic app, the cookie works, but when I don't use it, it doesn't work as I mentioned above. It seems that by doing the hardware back button in the InAppBrowser the cache is not maintained or it is not loaded. All this without changing anything in the code.

So I'm asking if there is a way that when I do the hardware back button it loads the previous page with the cookie/cache loaded. Or if it really shouldn't load anything since the filter has already been applied and the cookie has been overwritten.

What is expected to happen?

What I expect to happen is that when, for example, a user has used a filter from the web application, when the hardware back button is made, that filter (saved in the cookie) is maintained, just as it does when using the web application. on a PC.

What does actually happen?

What happens right now is that when using the hardware back button the filter that had been made disappears, but the thing is that the cookie still exists, since using the DevTools it works without having made any changes to the code.

Information

Command or Code

This is how I create the InAppBrowser:

browser = this.iab.create(pageContentUrl, '_blank', 'location=no,zoom=no,fullscreen=no,clearcache=no,clearsessioncache=no,hidden=yes,toolbar=no');

I have this to check the cookie:

browser.on('loadstart').subscribe((e: InAppBrowserEvent) => {
      browser.executeScript({
          code: "(function() { \
            console.log(document.cookie);\
          })();"
        });
});

Update

I've test this under onCreate in MainActivity (Android Studio) and it doesn't fix the issue:

public class MainActivity extends BridgeActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);

    if(webView.canGoBack()){
      webView.goBack();
    }
  }
}

Environment, Platform, Device

  • Android 11 - Samsung Galaxy A12

Version information

Ionic info:

Ionic:
-    Ionic CLI                     : 6.20.1 (C:\Users\david\AppData\Roaming\npm\node_modules\@ionic\cli)
-    Ionic Framework               : @ionic/angular 6.2.5
-    @angular-devkit/build-angular : 14.2.1
-    @angular-devkit/schematics    : 14.2.1
-    @angular/cli                  : 14.2.1
-    @ionic/angular-toolkit        : 6.1.0

Capacitor:
-    Capacitor CLI      : 4.1.0
-    @capacitor/android : 4.1.0
-    @capacitor/core    : 4.1.0
-    @capacitor/ios     : 4.1.0

Utility:
-    cordova-res : 0.15.4
-    native-run  : 1.6.0

System:
-    NodeJS : v16.15.1 (C:\Program Files\nodejs\node.exe)
-    npm    : 8.11.0
-    OS     : Windows 10

List of plugins installed and dependencies from package.json :

"@angular/common": "^14.0.0",
"@angular/core": "^14.0.0",
"@angular/forms": "^14.0.0",
"@angular/platform-browser": "^14.0.0",
"@angular/platform-browser-dynamic": "^14.0.0",
"@angular/router": "^14.0.0",
"@awesome-cordova-plugins/device": "^5.44.0",
"@awesome-cordova-plugins/http": "^5.44.0",
"@awesome-cordova-plugins/in-app-browser": "^6.3.0",
"@awesome-cordova-plugins/network": "^5.45.0",
"@awesome-cordova-plugins/screen-orientation": "^5.45.0",
"@capacitor/android": "4.1.0",
"@capacitor/app": "4.0.1",
"@capacitor/core": "4.1.0",
"@capacitor/device": "^4.1.0",
"@capacitor/haptics": "4.0.1",
"@capacitor/ios": "4.1.0",
"@capacitor/keyboard": "4.0.1",
"@capacitor/local-notifications": "^4.1.0",
"@capacitor/push-notifications": "^4.1.0",
"@capacitor/status-bar": "4.0.1",
"@capacitor/toast": "^4.1.0",
"@ionic/angular": "^6.1.9",
"@ionic/storage-angular": "^3.0.6",
"cordova-plugin-advanced-http": "^3.3.1",
"cordova-plugin-device": "^2.1.0",
"cordova-plugin-file": "^7.0.0",
"cordova-plugin-inappbrowser": "^5.0.0",
"cordova-plugin-lottie-splashscreen": "github:timbru31/cordova-plugin-lottie-splashscreen",
"cordova-plugin-network-information": "^3.0.0",
"cordova-plugin-screen-orientation": "^3.0.2",
"ionicons": "^6.0.3",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant