Opening all links in in-app-browser?

Hello i’m trying to open all links in the in app browser. I tried the solutions in this topic:

But it’s still not working.

My current code:

import {Component, ViewChild} from '@angular/core';
import {Platform} from 'ionic-angular';
import {NavController} from 'ionic-angular';
import {OneSignal} from '@ionic-native/onesignal';
import {InAppBrowser} from '@ionic-native/in-app-browser';

declare var window: any;

    templateUrl: 'app.html',
    providers: [InAppBrowser]

export class MyApp {
        @ViewChild(NavController) navCtrl: NavController;

    constructor(public platform: Platform, private oneSignal: OneSignal, private inAppBrowser: InAppBrowser) {
        platform.ready().then(() => {

           //Check if the app isn't run in a browser.
            if ('core') ||'mobileweb')) {
                // Do not use cordova services
            } else { = (url, target?, opts?) => new inAppBrowser(url, target, opts);

The new inAppBrowser(url, target, opts); is red underlined in my IDE.
The error I get is: ‘Cannot use ‘new’ with an expression whose type lacks a call or construct signature.’

Does anyone know what I can do to fix it? I’m running the latest version of Ionic.

I also tried using: =;
But then the links don’t work at all.

Fixed it by using this tutorial and making it a service.

Can you please give the code you use?


+1 for me, need it too