Capacitor: Browser addListener not working

Created on 5 Mar 2019  Â·  5Comments  Â·  Source: ionic-team/capacitor

Hello I have problem I test Capacitor on my App and I want run browser and use addListner to observe change url.

I have this code:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ModalController } from 'ionic-angular';
import { Plugins } from '@capacitor/core';
const { Browser } = Plugins;

export class HomePage {
constructor(){

  Browser.addListener("browserFinished", (info: any) => {
    console.log(info.url);
  })

}
  async openWebpage(url: string) {
    await   Plugins.Browser.open({ url: 'http://capacitor.ionicframework.com/' });
}
}

When I pushed the button, Browser Start but addListener don't give me event with console.log.

Please tell me what is wrong.

Ionic 4.10.3 but project is created on ionic 3
Cordova 8.1.2 ([email protected])

Most helpful comment

This is such a fundamental missing thing from Capacitor - for example when you need to take the user to a site to perform some action and then help them return to the app when completed.
The inappbrowser in cordova was very widely used to support this.
I understand why you keep closing the ticket because it is an inconvenience to incorporate a non-chrome based browser, but this is such a pain in the *ss for so many of us, for so long, it is really hindering the uptake of capacitor.
A plea to the Ionicframework folks: make @ionic-enterprise/inappbrowser available to all!

All 5 comments

Is this on iOS? Android? browser?

On android

śr., 6.03.2019, 16:21 użytkownik jcesarmobile notifications@github.com
napisał:

Is this on iOS? Android? browser?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ionic-team/capacitor/issues/1291#issuecomment-470147616,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABgJEyNWi6b4p6fe3MrhB7yWNVYqgjc_ks5vT9zvgaJpZM4beqPr
.

You can't observe the url change in Browser plugin
I've added browserPageLoaded implementation for Android, but it only tells you it finished loading, not the url. https://github.com/ionic-team/capacitor/pull/1293
browserFinished is for when you close the browser, not for when the navigation finishes, but it's not possible to know on Android, so going to close the issue.

Hello Ionic Team,

Browser Plugin with event browserPageLoaded doesn't give the url or info about the page has been loaded.

How to check if a specific route has been loaded?

I use this to check if the user finished payment and it redirected to a specific success page so then I close the browser.

It was working in cordova plugin "In App Browser".

Should I user the cordova "In App Browser" plugin instead??

This is such a fundamental missing thing from Capacitor - for example when you need to take the user to a site to perform some action and then help them return to the app when completed.
The inappbrowser in cordova was very widely used to support this.
I understand why you keep closing the ticket because it is an inconvenience to incorporate a non-chrome based browser, but this is such a pain in the *ss for so many of us, for so long, it is really hindering the uptake of capacitor.
A plea to the Ionicframework folks: make @ionic-enterprise/inappbrowser available to all!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielsogl picture danielsogl  Â·  3Comments

stripathix picture stripathix  Â·  3Comments

peterpeterparker picture peterpeterparker  Â·  3Comments

daniel-lucas-silva picture daniel-lucas-silva  Â·  3Comments

json-derulo picture json-derulo  Â·  3Comments