You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/04/15 14:23:50 UTC

[GitHub] [cordova-plugin-inappbrowser] lbod removed a comment on issue #571: 'beforeload' event can only fire once in an InAppBrowser session

lbod removed a comment on issue #571:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/571#issuecomment-820439266


   Has anyone had any sort of success with this? I've just ran into the same issue, however the solution recommended by @wvengen is not relevant, nor does it fix it. We had already ran into a similar issue when using the `message` event after launching a system window, so we already were unsubscribing then resubscribing to reattach event handlers.
   
   We too also want to intercept all navigation changes and conditionally load the system browser. I went back to basics and did a basic test without any system window and the `beforeload` event fires every second time as soon as you use `_loadAfterBeforeload()` to continue the URL navigation.
   
   **The code below fires the `beforeload` event on every navigation change**
   
   ```
     public openIIAB(evt: Event) {
       const options: InAppBrowserOptions = {
         beforeload: 'yes'
       }
       const inAppBrowserRef = this.inAppBrowser.create(this.url, '_blank', options);
       inAppBrowserRef.show();
       inAppBrowserRef.on('beforeload').subscribe((resp) => {
         console.log(`===> beforeload resp.url (${resp.url});`)
       });
     }
   ```
   
   **The code below fires the `beforeload` event every second navigation change**
   
   ```
     public openIIAB(evt: Event) {
       const options: InAppBrowserOptions = {
         beforeload: 'yes'
       }
       const inAppBrowserRef = this.inAppBrowser.create(this.url, '_blank', options);
       inAppBrowserRef.show();
       inAppBrowserRef.on('beforeload').subscribe((resp) => {
         console.log(`===> beforeload resp.url (${resp.url});`);
         if (resp.url.startsWith(this.baseUrl)) {
           console.log(`===> beforeload matched baseUrl, calling _loadAfterBeforeload() `);
           inAppBrowserRef._loadAfterBeforeload(resp.url);
         } else {
           console.log(`===> beforeload not matched baseUrl, do nothing`);
         }
       });
     }
   ```
   
   This only effects Android, the IOS plugin works fine. I've also tried with the latest version 5.0.0, we were using 4.1.0. I've tried to debug InAppBrowser.java and try get an understanding what's going on but my knowledge of Android isn't good enough to understand.
   
   There seems to be lots of bugs raised for very similar issues and this issue was raised a year and a half ago with no solution so I'm not holding out much hope unless I'm able to figure out what's happening in the plugin itself, which I think I'd be unlikely to do. The only other option is to descope this requirement for Android
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org