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

孤街浪徒 提交于 2019-12-11 00:52:26

问题


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:


just use e.url

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


来源:https://stackoverflow.com/questions/41194745/how-to-get-current-url-on-exit-event-inappbrowser-ionic2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!