Cannot open Inappbrowser in android

I am using latest version of Ionic 2 and I am not able to open inappbrowser in Android device. It works fine for iOS simulator as well as device. It is not even throwing any error. I added eventlisteners and it is not getting fired

1 Like
  • 1

I’m having the same problem.

Can you post the exact code? How did you install the plugin?

I added the plugin using - "ionic plugin add cordova-plugin-inappbrowser"
and tried opening browser as follows:

cordova.InAppBrowser.open(“http://www.google.com”, ‘_blank’, “location=yes”);

Also tried:
window.open(“http://www.google.com”, ‘_blank’, “location=yes”);

Did you have

<access origin="*" />
<gap:plugin name="org.apache.cordova.inappbrowser" version="x.x.x" />

in your config.xml

I’m having the same problem as clientdesk but when I insert this into config.xml I get a build error of AAPT: Error parsing XML: unbound prefix.

I added the gap:plugin line below the access line in the config, is this not the correct place for it?

config.xml for reference:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <widget id="com.ionicframework.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>HelloCordova</name> <description> An Ionic Framework and Cordova project. </description> <author email="you@example.com" href="http://example.com.com/"> Your Name Here </author> <content src="index.html"/> <access origin="*"/> <gap:plugin name="org.apache.cordova.inappbrowser" version="x.x.x" /> <preference name="webviewbounce" value="false"/> <preference name="UIWebViewBounce" value="false"/> <preference name="DisallowOverscroll" value="true"/> <preference name="SplashScreenDelay" value="2000"/> <preference name="FadeSplashScreenDuration" value="2000"/> <preference name="android-minSdkVersion" value="16"/> <preference name="BackupWebStorage" value="none"/> <preference name="SplashScreen" value="screen"/> <feature name="StatusBar"> <param name="ios-package" value="CDVStatusBar" onload="true"/> </feature> <platform name="android"> <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/> <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/> <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/> <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/> <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/> <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/> <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/> <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/> <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/> <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/> <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/> <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/> </platform> </widget>

You need declare the cordova var, like

declare var cordova: any;

I have the same problem with “cordova-plugin-inappbrowser”: “^1.7.1”,

I open the browser in this way:

options = "location=yes,hidden=yes";
target = "_self";
...
const browser = this.iab.create(this.mceUrl,this.target,this.options);

It works with IonicView but the apk does not work on Android 6.0.1.
It does not follow the link.

Which could be the problem?

thank you

cld

Hi.
I have same problem. Did you fix it?
Thank you

Sorry, I don’t remember, however now it works and this is the code I’m using:

import { BarcodeScanner } from '@ionic-native/barcode-scanner';
...
  constructor(private app: App, 
              private barcodeScanner: BarcodeScanner) { 
 }
...
actionScanQrCode() {
...
      this.barcodeScanner.scan().then((barcodeData) => {
        if (!barcodeData.cancelled) {
          this.mceFormat = barcodeData.format;
          if (this.mceFormat=='QR_CODE') {
            url = barcodeData.text;
            machineId = this.getMachineIdFromUrl(url);
            ....
          } else {
              alert("Sorry, this is not a valid QRCode.");
              return "";
          }
        }
      }, (err) => {
        alert(err);
      });
...
}

No) I was wondering about “cordova-plugin-inappbrowser”.
“It works with IonicView but the apk does not work on Android 6.0.1.
It does not follow the link.”
:slight_smile:

Excuse me,
yes I sent you the wrong code.

However I remember that I had a similar problem, but now looking to my code I can see that now I’m using an “iframe” to show the content of a remote site.

However I used this guide when I was using the inappbrowser.
And you have to modify the config.xml as described in the previous posts.

cld