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

beforeload event behaviour difference between android and ios #1071

Open
wmadev opened this issue Sep 13, 2024 · 0 comments
Open

beforeload event behaviour difference between android and ios #1071

wmadev opened this issue Sep 13, 2024 · 0 comments

Comments

@wmadev
Copy link

wmadev commented Sep 13, 2024

Bug Report

Problem

What is expected to happen?

We are using the inappbrowser to load our initial app page. After we add a listener to the "beforeload" event to intercept every next load. We check if this is an internal url from our app, if not we want the link to open in the system browser and not in the inappbrowser.

What does actually happen?

On Android this seems to work. Our first page opens, and a beforeload event is coming for every next load so we can intercept this properly. With navigator.app.loadUrl we manage to open the links in the android system browser.

On IOS this does not work. We are getting a beforeload event already for our first page which is different from android where we don't get this first event. Secondly the navigator.app.loadurl doesn't work on iOS. From what I read window.open(), cordova.InAppBrowser.open() should work but the first doesn't work, and 2nd only works for the first external link we click. For the 2nd nothing at all happens. (doesn't load in the inappbrowser, but also not in an external browser)

Information

Command or Code

     inAppBrowserRef = cordova.InAppBrowser.open("initial_url", '_blank',"beforeload=yes");

inAppBrowserRef.addEventListener('beforeload', function(params, callback){
             if(externalUrl(param)){
                 if(device.platform.toUpperCase() === 'ANDROID'){
                    navigator.app.loadUrl(params.url,{openExternal:true});
                 }else if(device.platform.toUpperCase() === 'IOS'){
                      window.open(params.url,'_system');
                 }
             }
        });

Environment, Platform, Device

IOS

Version information

"devDependencies": {
"cordova-android": "^12.0.1",
"cordova-ios": "^7.1.0",
"cordova-plugin-device": "^2.1.0",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-inappbrowser": "^6.0.0",
"cordova-plugin-splashscreen": "^6.0.1",
"cordova-plugin-statusbar": "^4.0.0"
},

Checklist

  • [ x] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [ x] 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