fburian commented on issue #539:
URL: 
https://github.com/apache/cordova-plugin-inappbrowser/issues/539#issuecomment-1952604230

   Unfortunately, this is not possible under Cordova because iab.on('message') 
does not exist as a function.
   
   I simply start a new instance of the InAppBrowser when the app comes back to 
the foreground from the background. I make sure internally that I cache the 
current URL so that I always reload the last page.
   
   The code could look something like this:
   
   `var currentUrl = 'https://example.com';
   
   document.addEventListener("deviceready", onDeviceReady, false);
   
   function onDeviceReady() {
       // Start default page 
       openIAB(currentUrl);
       // Event when app goes to foreground
       document.addEventListener('resume', resumeToApp, false);  
   }
   
   function openIAB(url) {
       // Open InAppBrowser
       var iab = cordova.InAppBrowser.open(url, "_blank", 
'usewkwebview=yes,hidden=yes,hardwareback=no,toolbar=no,hidenavigationbuttons=yes');
       // Store current url
       iab.addEventListener('loadstart', function(e) { 
           currentUrl = e.url;
       });
   }
   
   function resumeToApp() {
       openIAB(currentUrl);
   }`
   
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

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


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

Reply via email to