how to get current url, on exit event InAppBrowser, Ionic2

1.3k views Asked by At

I am trying to implement a solution where I need to get the current url on exit event of InAppBowser Ionic2.

My Code is

import { Component } from '@angular/core';

import { NavController, NavParams } from 'ionic-angular';
import {InAppBrowser} from 'ionic-native';


@Component({
  selector: 'page-list',
  templateUrl: 'list.html'
})
export class ListPage {
  browser:any;
  exit:boolean = false;
  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  startPayment(){
    this.browser = new InAppBrowser('https://ionic.io', '_blank','location=no,toolbar=no,hardwareback=no,EnableViewPortScale=yes,closebuttoncaption=Done');
    this.browser.on("exit")
            .subscribe(
            (e) => {
                this.checkpaymentStatus(e);
            },
            err => {
                console.log("InAppBrowser loadstart Event Error: " + err);
            });
  };

  checkpaymentStatus(e){
    console.log(e);
    console.log("in app browser exit")
    this.exit = true;
  }    
};//

The exit event is firing properly but I am unable to get the url in event(e), it just gives Object{type:exit}.

Please tell me , how can I get the url on exit. Thanks

1

There are 1 answers

3
sadiq On

just use e.url

checkpaymentStatus(e){
    console.log(e.url); // you will get url here
    // ... ... ...
}