Search code examples
ioscordovacordova-pluginsbarcode-scannerinappbrowser

Cordova iOS - InAppBrowser always on top issue


I am creating an Apache Cordova app. I have added InAppBrowser plugin and barcode scanner plugin that is invoked from the page opened inside InAppBrowser through cross browser communication. It is running perfectly fine in Android. But when ran in iOS, the InAppBrowser acts like a modal pop-up and doesn't let barcode scanner appear until the InAppBrowser is closed/dismissed.

I have confirmed that barcode scanner is working even when in background but it just won't appear because the InAppBrowser is always on top.

I'm thinking that there could be a workaround to give barcode scanner plugin maximum z-index but I cannot figure out how.

I also tried to hide the InAppBrowser, but it didn't work in iOS.

cordova.InAppBrowser.hide();

My idea is to extend my website to use native features when running from its mobile app.


Solution

  • I forgot to add an answer here. But I fixed it the very next day. The fix is very straight forward, I changed the hide and show methods of InAppBrowser to the following:

    - (void)hide:(CDVInvokedUrlCommand*)command {
     self.inAppBrowserViewController.viewController.hidden = YES;
    }
    
    - (void)hide:(CDVInvokedUrlCommand*)command {
     self.inAppBrowserViewController.viewController.hidden = NO;
    

    }