You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In inappbrowser, If the user click on external intent link with fallback URL (e.g.: 3rd party websites) and when an intent could not be resolved, or an external application could not be launched, then the user will be redirected to the fallback URL if it was given.
What does actually happen?
If the user click on an intent link with fallback URL and when an intent could not be resolved, or an external application could not be launched, the inappbrowser cannot handle the fallback url and the webview generate the following error messagge:
Could not load because of net::ERR_UNKNOWN_URL_SCHEME
A little known feature in Android lets you launch apps directly from a web page via an Android Intent. One scenario is launching an app when the user lands on a page, which you can achieve by embedding an iframe in the page with a custom URI-scheme set as the src, as follows: <iframe src="paulsawesomeapp://page1"> </iframe>. This works in the Chrome for Android browser, version 18 and earlier. It also works in the Android browser, of course.
The functionality has changed slightly in Chrome for Android, versions 25 and later. It is no longer possible to launch an Android app by setting an iframe's src attribute. For example, navigating an iframe to a URI with a custom scheme such as paulsawesomeapp:// will not work even if the user has the appropriate app installed. Instead, you should implement a user gesture to launch the app via a custom scheme, or use the "intent:" syntax described in this article.
Syntax
The best practice is to construct an intent anchor and embed that into the page so the user can launch the app. This gives you a lot more flexibility in controlling how apps are launched, including the ability to pass extra information into the app via Intent Extras.
The basic syntax for an intent-based URI is as follows:
Also, you may choose to specify fallback URL by adding the following string extra:
S.browser_fallback_url=[encoded_full_url]
When an intent could not be resolved, or an external application could not be launched, then the user will be redirected to the fallback URL if it was given.
Some example cases where Chrome does not launch an external application are as follows:
The intent could not be resolved, i.e., no app can handle the intent.
JavaScript timer tried to open an application without user gesture.
Note that S.<name> is a way to define string extras. S.browser_fallback_url was chosen for backward compatibility, but the target app won't see browser_fallback_url value as Chrome removes it.
Examples
Here's an intent that launches the Zxing barcode scanner app. It follows the syntax thus:
intent: //scan/ #Intent; package=com.google.zxing.client.android; scheme=zxing; end;
To launch the Zxing barcode scanner app, you encode your href on the anchor as follows:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end"> Take a QR code </a>
Also, if fallback URL is specified, the full URL will look like this:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end"> Take a QR code </a>
Now the URL will get you to zxing.org if the app could not be found, or the link was triggered from JavaScript without user gesture (or for other cases where we don't launch an external application.)
Considerations #
If the activity you invoke via an intent contains extras, you can include these as well.
Only activities that have the category filter, android.intent.category.BROWSABLE are able to be invoked using this method as it indicates that the application is safe to open from the Browser.
Command or Code
Environment, Platform, Device
Android
Version information
cordova-plugin-inappbrowser v5.0.0 and master
cordova-android v9.1.0 and master
Checklist
I searched for existing GitHub issues
I updated all Cordova tooling to most recent version
I included all the necessary information above
The text was updated successfully, but these errors were encountered:
mosabab
changed the title
[Android] Inappbrowser cannot handle the intent links with fallback URL
[Android] Inappbrowser cannot handle the intent links when fallback URL is specified
Jun 23, 2021
mosabab
changed the title
[Android] Inappbrowser cannot handle the intent links when fallback URL is specified
[Android] Inappbrowser cannot handle specified fallback URL in intent links
Jun 23, 2021
mosabab
changed the title
[Android] Inappbrowser cannot handle specified fallback URL in intent links
[Android] Inappbrowser cannot read specified fallback URL in intent links
Jun 23, 2021
mosabab
changed the title
[Android] Inappbrowser cannot read specified fallback URL in intent links
[Android] Inappbrowser cannot read specified fallback URL in intent scheme links
Jun 25, 2021
Bug Report
Problem
[Android] Inappbrowser cannot read specified fallback URL in intent scheme links
What is expected to happen?
In inappbrowser, If the user click on external intent link with fallback URL (e.g.: 3rd party websites) and when an intent could not be resolved, or an external application could not be launched, then the user will be redirected to the fallback URL if it was given.
What does actually happen?
If the user click on an intent link with fallback URL and when an intent could not be resolved, or an external application could not be launched, the inappbrowser cannot handle the fallback url and the webview generate the following error messagge:
Could not load because of net::ERR_UNKNOWN_URL_SCHEME
Information
You may need the user to open external apps, so we need to handle this situation.
According to Google Chrome for Android (Android Intents with Chrome)
https://developer.chrome.com/docs/multidevice/android/intents/
The following information describe the problem:
A little known feature in Android lets you launch apps directly from a web page via an Android Intent. One scenario is launching an app when the user lands on a page, which you can achieve by embedding an iframe in the page with a custom URI-scheme set as the src, as follows:
<iframe src="paulsawesomeapp://page1"> </iframe>
. This works in the Chrome for Android browser, version 18 and earlier. It also works in the Android browser, of course.The functionality has changed slightly in Chrome for Android, versions 25 and later. It is no longer possible to launch an Android app by setting an iframe's src attribute. For example, navigating an iframe to a URI with a custom scheme such as
paulsawesomeapp://
will not work even if the user has the appropriate app installed. Instead, you should implement a user gesture to launch the app via a custom scheme, or use the "intent:" syntax described in this article.Syntax
The best practice is to construct an intent anchor and embed that into the page so the user can launch the app. This gives you a lot more flexibility in controlling how apps are launched, including the ability to pass extra information into the app via Intent Extras.
The basic syntax for an intent-based URI is as follows:
intent: HOST/URI-path // Optional host #Intent; package=\[string\]; action=\[string\]; category=\[string\]; component=\[string\]; scheme=\[string\]; end;
Also, you may choose to specify fallback URL by adding the following string extra:
S.browser_fallback_url=[encoded_full_url]
When an intent could not be resolved, or an external application could not be launched, then the user will be redirected to the fallback URL if it was given.
Some example cases where Chrome does not launch an external application are as follows:
Note that
S.<name>
is a way to define string extras.S.browser_fallback_url
was chosen for backward compatibility, but the target app won't seebrowser_fallback_url
value as Chrome removes it.Examples
Here's an intent that launches the Zxing barcode scanner app. It follows the syntax thus:
intent: //scan/ #Intent; package=com.google.zxing.client.android; scheme=zxing; end;
To launch the Zxing barcode scanner app, you encode your href on the anchor as follows:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end"> Take a QR code </a>
Also, if fallback URL is specified, the full URL will look like this:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end"> Take a QR code </a>
Now the URL will get you to zxing.org if the app could not be found, or the link was triggered from JavaScript without user gesture (or for other cases where we don't launch an external application.)
Considerations #
If the activity you invoke via an intent contains extras, you can include these as well.
Only activities that have the category filter, android.intent.category.BROWSABLE are able to be invoked using this method as it indicates that the application is safe to open from the Browser.
Command or Code
Environment, Platform, Device
Android
Version information
cordova-plugin-inappbrowser v5.0.0 and master
cordova-android v9.1.0 and master
Checklist
The text was updated successfully, but these errors were encountered: