I can't open a new window in iOS

In my app I’m trying to open a web page. It works fine in Android and in a browser, but not in iOS.

I’ve tried all variations of window.open(…), and this.inAppBrowser.create(…) and even this.browserTab.openUrl(…). But nothing does anything. Nothing. Not even an error. When you click the button to open the link, nothing opens.

I’ve tried uninstalling and reinstalling cordova-plugin-inappbrowser. I think I’ve tried uninstalling and reinstalling Android and iOS platforms.

This is some of my config.xml:

  <allow-navigation href="*" />
    <allow-intent href="*" />
    <access origin="*" />
    <engine name="ios" spec="4.5.4" />
    <engine name="android" spec="6.3.0" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="cordova-plugin-network-information" spec="^2.0.1" />
    <plugin name="cordova-plugin-ionic" spec="^4.0.0">
        <variable name="APP_ID" value="something" />
        <variable name="CHANNEL_NAME" value="Production" />
        <variable name="UPDATE_METHOD" value="none" />
        <variable name="WARN_DEBUG" value="true" />
        <variable name="UPDATE_API" value="https://api.ionicjs.com" />
        <variable name="MAX_STORE" value="2" />
    </plugin>
    <plugin name="cordova-plugin-device" spec="^2.0.1" />
    <plugin name="cordova-plugin-statusbar" spec="^2.4.1" />
    <plugin name="cordova-plugin-calendar" spec="^5.0.0">
        <variable name="CALENDAR_USAGE_DESCRIPTION" value=" " />
    </plugin>
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-sqlite-storage" spec="^2.2.1" />
    <plugin name="cordova-plugin-background-mode" spec="^0.7.2" />
    <plugin name="cordova-plugin-add-swift-support" spec="^1.7.1" />
    <plugin name="cordova-plugin-inappbrowser" spec="^2.0.2" />
    <plugin name="cordova-plugin-browsertab" spec="^0.2.0" />

This is part of my ionic info:

cli packages: (C:\Users\timk\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.5
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.10.0
    npm  : 5.6.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

Any ideas are welcome. I’ve tried to get this working for a few days now, and I’m running out of ideas.

Thanks.

1 Like

I’m having the same issue.

I haven’t tried adding the in-app browsers. I will try that, but if it isn’t working for you I imagine I will have the same issue. Without the in-app browser installed, would it normally open the system web browser?

It’s supposed to open in the system browser if you specify the target of “_system”, like this:

window.open(url, '_system')
or
this.inAppBrowser.create(url, '_system')

But neither is working for me.

I don’t know what is supposed to happen if you don’t add the ‘_system’.

1 Like

I got it working by adding the in-app browser package and using window.open(). Hope you get it working soon. Good luck. Thanks for your help.

I solved this by adding this line to my config.xml, in the ios platform section:

<allow-navigation href="*" />

3 Likes

Thanks for sharing. I am having the same problem with BrowserTab. Put it right here.

Yeah, it did the trick!

This didn’t work for me. I solved the issue with this (with cordova@9.0.0):

  1. Install InAppBrowser for ionic v3:
  1. Import in your app.module.ts.
  2. Add in your Class to use.
  3. Add this line (instead of window.open('url', '_system') )
    this.iab.create('url', '_system');

Where this.iab is declared in constructor Class:

import { InAppBrowser } from '@ionic-native/in-app-browser';

@Component({
  selector: 'login-page',
  templateUrl: 'login.html'
})
export class LoginPage {
  constructor(private iab: InAppBrowser) {}

  yourMethodtoUse() {
    // ...
    // Open navigator here - iOS ionic v3
    this.iab.create('https://www.google.com/myAccount', '_system');
    // ...
  }
}

Tested in iOS 13.6 in iPhone 11 Pro.

1 Like