Redirection to WhatsApp application from custom URL - javascript

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

Related

alternative of URL scheme for launching application in ios from another application?

Target Application is not having any URL scheme, and i want invoke it with my application.
I also want to redirect to Apple store if the user doesn't have that application installed.
Please tell me if there is any other way to open an application from Cordova plugin or JavaScript. Thanks in advance.
Sorry. But unless you have a jailbroken device, there's no way to open another app other than via URL scheme, i.e. (Swift): UIApplication.open(_:options:completionHandler:)
This is so by intention since Apple wants the apps sandboxed and therefore strictly limits the ways apps can interact. Launching via URL is the only way they permit app launching.

Android Chrome and intents detections

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

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.

iOS link to standalone webapp

I am making a standalone webapp for a client, and he would be able to access to another website sometimes. So I made a link which open a tab in Safari (quit fullscreen) but then I wish I could return to the standalone app either by a link or by the address bar (without homescreen button which is locked).
Is there any way to make a link that go to a standalone web ? Or using javascript to open in fullscreen app ?
I hope Iwas clear enough, not easy to explain ^^
You can register a custom url scheme that links to your app. Basically, in your app .plist you register a scheme like "myapp", and any link that uses de protocol myapp://xxx would launch your app and pass whatever you add after the // ("xxx" in the previous example).
It's exactly like "mailto:" links, but opening your app instead of the Mail app :)
You can check how to configure your app in XCode looking at this answer: https://stackoverflow.com/a/12784399/201059
As you don't specify what platform you are using for packaging your WebApp, I can't give you further info, but if you were using Cordova/Phonegap you could install a plugin to receive the params after myapp://, so that you could go to a specific page/screen (ex: myapp://customercard?id=1234)
Update, regarding HoffZ's comment below:
When benuuts mentioned that it was a standalone webapp I understood that it was packaged with Cordova or a similar framework. If that it's not the case, unfortunately I'm not aware of any way to return to a fullscreen (pinned to the home screen) webapp.

How to share mobile browser url to whatsapp on button click using jquery?

I want to share my mobile browser url through whatsapp using custom button...is it possible?
Like that (When i click on button , mobile whatsapp open if it is there otherwise it will display "WhatsApp not Installed")
iOS
In iOS you can use a URL scheme for that.
In a nutshell, URL schemes are special URLs that are registered by native applications so that any other application navigating to that URL is forwarding their request to the native app associated with that URL scheme.
Check out this link on the whatsapp website which explains how to use the URL scheme.
Android
In Android you deal with this in a different way. Android uses Intents and Activities.
You can check out this to a similar question.
This will work

Categories

Resources