Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug (Capacitor Browser): browserFinished | browserPageLoaded does not return anything #3044

Closed
2 of 4 tasks
indraraj26 opened this issue Jun 3, 2020 · 11 comments
Closed
2 of 4 tasks

Comments

@indraraj26
Copy link

Bug Report

Capacitor Version

npx cap doctor output:

npx cap doctor
   Capacitor Doctor 
  
Latest Dependencies:
  @capacitor/cli: 2.1.2
  @capacitor/core: 2.1.2
  @capacitor/android: 2.1.2
  @capacitor/ios: 2.1.2

Installed Dependencies:
  @capacitor/ios not installed
  @capacitor/cli 1.4.0
  @capacitor/core 2.1.2
  @capacitor/android 2.1.2
[success] Android looking great! 👌

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

This event doesnt return anything in callback

Expected Behavior

It should return something

Sample Code or Sample Application Repo

async openUrl() {
		if (Capacitor.isPluginAvailable('Browser')) {
			await Browser.open({
				url: 'http://capacitor.ionicframework.com/',
			});
			Browser.addListener('browserFinished', (err, result) => {
				console.log(err, result, 'browserFinished');
				if (err) {
					return console.warn('[Browser-Finished] Something went wrong!');
				}
				console.log(result, 'Browser Finished Listen Result');
			});
			Browser.addListener('browserPageLoaded', (err, result) => {
				console.log(err, result, 'BrowserPageLoad');
				if (err) {
					return console.warn('[Browser-PageLoad] Something went wrong!');
				}
				console.log(result, 'Browser PageLoad Listen Result');
			});
		} else {
			console.log('capacitor browser is not available');
		}
	}

Reproduction Steps

Other Technical Details

npm --version output: 6.9.0

node --version output: v10.16.3

pod --version output (iOS issues only):

Other Information

@jcesarmobile
Copy link
Member

This is not a bug, they don't return anything on any platform, so tagging as feature request.

Issues tagged with feature request are closed but tracked for👍 reactions to gauge interest.

Would be good to know what do you expect them to return, but the native API is very limited, so there is not really a lot of things to return.

@devdarji96
Copy link

In the return we should get changed url so we can use it.

@jcesarmobile
Copy link
Member

That's not provided by SFSafariViewController nor by Chrome Custom Tabs that the plugin uses, so not really possible.

@devdarji96
Copy link

Ok thanks Man to inform.

@indraraj26
Copy link
Author

I would like to have same features in this capacitor plugin like we have in cordova in-app browser

@jcesarmobile
Copy link
Member

As I said, it's not possible because this plugin uses SFSafariViewController on iOS and Chrome Custom Tabs, and while it has some advantages over using a webview (what InAppBrowser plugin uses), it also has some limitations, like not being able to know the urls you are loading, or not being able to inject javascript or css. This is by design because Apple and Google thing those features affect security and privacy and the focus of those components is precisely improving the security and privacy.

So if you need those features, keep using cordova's InAppBrowser plugin or create a Capacitor plugin that uses a webview to load the content.

@indraraj26
Copy link
Author

okay i get it. thank you for explanation

@donfour
Copy link

donfour commented Jul 28, 2020

If not returning anything is the expected behavior, then the docs should not show (info: any) => void as the listener function's signature. It is very misleading.

@jofftiquez
Copy link

If not returning anything is the expected behavior, then the docs should not show (info: any) => void as the listener function's signature. It is very misleading.

I couldn't agree more. Please fix the documentation. I wonder how many people were misled because of this.

@jcesarmobile
Copy link
Member

removing the labels since this feature is not going to be possible due to the limitations of the native components used byt the plugin (SFSafariViewController on iOS and Chrome Custom Tabs on Android) as they prioritize security vs functionality.

If people need that information they'll have to use cordova-plugin-inappbrowser or create a capacitor plugin that uses a webview, but SFSafariViewController and Chrome Custom Tabs don't provide that information, so we can't neither.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants