InAppBrowser phonecall confirmation

Hello,

I got a service with my inappbrowser module :

// WEB VIEW -------------------------

@Component({})
export class OpenWebview {
  constructor(private platform: Platform) {

  }

  public open(url, locationBar) {
    this.platform.ready().then(() => {
        if(this.platform.is('ios')) {
          cordova.InAppBrowser.open(url, "_blank", "location="+locationBar + ",enableViewportScale=yes,disallowoverscroll=yes,presentationstyle=pagesheet");
        } else {
          cordova.InAppBrowser.open(url, "_blank", "location="+locationBar);
        }
    });
  }
}

And in my page index.ts I create a loop to search all links and inject a webview if cordova is use

import {Component} from '@angular/core';
import {NavController, NavParams, Platform} from 'ionic-angular';
import {ClientService, OpenWebview} from '../services/services';

@Component({
  templateUrl: 'build/pages/elua/elua.html',
  providers: [ClientService, OpenWebview]
})
export class EluaPage {
  private menuState:any;
  private clientInfos:any;
  private eula:any;

  constructor(private nav: NavController, navParams: NavParams, private openwebview: OpenWebview, private platform: Platform) {
    var self = this;

    platform.ready().then(() => {
      this.openView();
    });
    
    this.menuState = navParams.get('menuState') || 'disabled';
    this.clientInfos = navParams.get('clientInfos');
    this.eula = this.clientInfos.eula;
  }

  openView() {
    var self = this;
    var links = document.getElementsByTagName('a');
    for (var i:number = 0; i < links.length; i++) {
      function whatClicked(evt) {
        evt.preventDefault();
        var url = evt.target.href;
        if (!self.platform.is('cordova')) {
          window.location.href = url;
        } else {
          self.openwebview.open(url, 'yes');
        }
      }
      links[i].addEventListener("click", whatClicked, false);
    }
  }
}

In browser it’s working perfectly but when I try to emulate on my Iphone (ionic view or build) or on ios-sim I got a white screen.

Somebody can help me please ?

Never use
for (var i:number; ...)
and use this.href instead of e.target.href

I’ve been doing quite a lot with the InAppBrowser in Ionic 2.

Firstly, I’d say that you should have this:

import {InAppBrowser} from 'ionic-native';

then instantiate the browser like this:

this.browser = InAppBrowser.open( this.target_URL, "_blank", "EnableViewPortScale=yes" );

After you have done this, try to test the InAppBrowser on a device.

The Ionic View does not support the InAppBrowser. I suspect that may be true of emulators too. You need to connect an actual device.

Hope that helps.

Tom

Now it’s working but for phone call, I need the confirmation call (include with InAppBrowser) but when I click on a phone number it’s open a confirmation call with a webview. Any ideas ?

In config.xml put <allow-navigation href="tel:*" /> instead <allow-intent href="tel:*" />