Android Chrome and intents detections - javascript

On Android, there are intents for apps as seen here:
https://developer.android.com/guide/topics/manifest/data-element.html
So if I have URL scheme www.google.com/calendar, Calendar app will be opened, etc.
However, I have question where/when this detection happens? I have experienced that tapping on the URL with supported scheme will cause intents recognition and if the scheme is recognised, the associated app will be opened. However, if I do redirection (javascript) to this supported URL in android Chrome, no recognition will happen so no redirection occurs. How can I build the URL in background (by tapping on the button), redirect to that URL and associated app will be opened?

That feature called Deep linking in android. As per document you can see
Open the user's preferred app that can handle the URI, if one is
designated.
Open the only available app that can handle the URI.
And for implementation you can refer this link

Related

Beforeinstallprompt not getting called in in-app browser

I have a pwa1 which will open in in-app browser of pwa2. I have install button for pwa1. But in in-app browser beforeinstallpromt is not getting fired. Any workaround for this?
Open in Chrome this link will open in chrome app from any other browser in Android except in-app browser of PWA. Any way to make it work for in-app browser?
Web share api shows lots of app when clicking share button except chrome app. Any way to add chrome app in sharing suggestions?
No, this only works in top-level browsing contexts according to the spec, but not in nested contexts.
Not that I know of, probably due to a similar limitation as above.
Chrome is not a share target, but you can copy the URL and open the URL on the clipboard with Chrome.

How does Zoom launch their desktop app from Google Chrome?

How does Zoom's website launch Zoom Meetings from Google Chrome?
Can I do it using JavaScript? If so, how can I do it?
Confirmation dialog box (Image)
It's not done with JavaScript, but with plain HTML. The way it works is, you create an <a> with an href attribute with a protocol other than the ones a browser usually recognizes - that is, other than http, https, etc.
If the user has installed an application that recognizes the protocol, the browser will try to open that application.
Similarly to Zoom, for IRC links, you can see something like:
Link
If you click on that link, and your machine has software installed that recognizes the irc protocol, that application can be opened directly by clicking on the link (possibly asking you if you want to open it first).
There are lots of different protocols for many different applications. They're quite handy for getting info on a web browser to an application on the user's computer.
For Zoom in particular, there's documentation on how to use its protocols here:
https://marketplace.zoom.us/docs/guides/guides/client-url-schemes
Making a link with a protocol registered to the zoom app on the operating system.

How do I detect the difference between Safari in Gmail Webview and Safari launched from Home Screen on iOS 11 when the User-Agent does not change?

I maintain an app that sends notifications to users containing links to forms. Those forms have image-capturing controls. These controls break in Safari when the app is opened in Safari through another app in a webview.
Okay, so I look at having Javascript detect if it is in a webview and try to direct the user to open their browser directly. Except, well, the user agent strings for Safari when opened via Gmail and Safari when opened directly from the Home screen on iOS 11 are identical.
So, all approaches for detecting webviews I currently see on Google like NPM's is-webview and User-Agent/regex predicates do not work. The only meaningful difference I can see is that navigator.mediaDevices.getUserMedia is undefined in the webview.
But knowing getUserMedia is undefined does not tell me if the user simply CANNOT use the controls, or if the user just needs to get directed to their default browser outside the scope of the app they used to access a notification.
Before we go through the trouble of decorating my links with additional data to track where users are coming from, is there a way to detect if Safari is opened via another app on iOS 11 if the user agent string does not change?

Redirection to WhatsApp application from custom URL

I have to prepare an analysis about redirecting from a web site to the WhatsApp appication in the purpose to send a message. I read the documentation at https://www.whatsapp.com/faq/android/28000012 and I noticed the use of whatsapp://send?text inside the href attribute of a link.
I want to know the behavior of this feature when WhatsApp is not installed in the user device and I found nothing about in the documentation.
Thats what you called deep linking. Using hyperlinks to redirect to your app when installed and to play store (if deployed to play store) when not installed. One example that uses deep linking is facebook, but facebook uses http uri which you can choose to open to the app or to the browser as the http uri scheme is known to be a browser's uri. If you are using custom uri, then the deep link must be triggered by a browser. Refer Here for example using deeplink in chrome browser https://developer.chrome.com/multidevice/android/intents

Open Android app through deep link if it's installed or fall back to web if not installed

I'm trying to create a web page that automatically opens an Android app but only if app is installed. In case it's not it should redirect to another web page.
The app is already in production and is properly handling deep links like example://content?id=42. The format of the link could not be changed.
What I've already tried
1) Redirects and timeout:
window.location.replace('example://content?id=42');
setTimeout(function() {
window.location.replace = 'http://example.com/content?id=42';
}, 500);
Works fine for iOS but for Android it redirects to example:// immediately and thus gives me ERR_UNKNOWN_URL_SCHEME. Seems to be no go for Android.
2) iframe approach. Impossible in rencent Chrome versions. Also doesn't seem to work in Samsung browser.
3) Intents with S.browser_fallback_url. Works well but in Chrome only. Doesn't work in Opera and Samsung browser... most probably nowhere else but Chrome 25+.
use http://example.com/content?id=42 as the link and add the intent filter to your activity in manifest
<intent-filter>
<data android:scheme="http" android:host="example.com" />
...
</intent-filter>
However, a list of app registered, e.g. browsers, will show up when the link is first accessed on the machine.
You need to be aware of the browser of the client, and its operating system and adapt your site to them. For example, if the browser is Chrome and the OS is Android, use the Intent solution; if the browser is Safari use the example:// schema. You can get the info looking at the User-Agent header of the request, but I'm sure there are many open source libraries that can help you to get infos related to browser and OS.
Seems like you could at least approximate the experience by letting the user give a one-time assist:
Have your web page itself have the fallback url content.
When the page is hit check the user agent to see if the os is Android
If its Android, show the user a choice prompt/dialog to use web or Android
If they choose web (remember the choice with local storage), dismiss the dialog and show the fallback
If they choose android (remember the choice), redirect to the app with the intent:// URL (without fallback_url), will take them to market to install if necessary
After the first interaction, it'll work as you describe - automatically taking them to the web page or the installed app.
You can try using this scheme(to be sent to the user):
intent://details?id=X&url=Y&referrer=Z#Intent;scheme=market;action=android.intent.action.VIEW;package=com.android.vending;end";
X: Package name of the App
Y: Deep link scheme which should be defined in the App's manifest.
(Please refer this)
Here, they have used this URL as an example: "http://www.example.com/gizmos" , therefore Y should be replaced by this URL.
Z: Can be any data which you want to pass to the App via Google Play.
Please take note that any data which you pass should not be '&' separated because the original parameters are itself '&' separated.
PS: The Google Play makes a broadcast to the app. So make sure you receive the broadcast in a receiver.

Categories

Resources