I have an android app that can be accessed through a web browser too. I need to put a banner to let the user install the android application. How can i tell (if the user enters to the application through the web browser) using javascript or jquery, if the android app is already installed on his mobile phone?
All i want to do is: If the user clics the banner and the app is already installed, open the android app. Otherwise, redirect the user to the playstore to let him install the app.
Let's say your app is uploaded on both Apple AppStore and Google Play stores.
You need to:
Sniff in your webpage which OS is installed from the device accessing your page
good link to find how => here
Enable deep linking to listen for exactly same link from your mobile native app
for Android you need to register your main activity or any other activity to listen for these links
for iOS - no idea honestly, look around or find a 3rd party service
code for Google Play with deep link. And the deep link is same as your website page you want to cache/index in Google Search (or any other search engine)
sample link to index/use => http://my_website.com/results
// below snipplet need to be for Android devices only
// i.e. need to sniff and have if/else validation for Android, iOS, desktop and so on
// will call with 25 mills delay in case deep link fails, i.e. no installed app
setTimeout(function () { window.location = "https://play.google.com/details?id=com.foo.myapp"; }, 25);
// try to load the deep link URL
window.location = "http://my_website.com/results";
repeat above for iOS and desktop/Windows Mobile
Additional advantage of above is the full app indexing without the lame App Indexing excuse from Google (min sdk no more than 17, Chrome for Android availability and so forth limitations).
There is no way to detect if an app is installed using Javascript.
However you can get the behavior you describe and you don't even need any javascript:
Choose an URL for your app on a web server you own and make the banner link to it.
Set this web URL as a deep link handled by your app by specifing it in your app's manifest. It should open the main Activity.
On your web server, configure this URL to redirect to the Play Store URL of your app. Optional: if your app is also on iOS, you could detect the iOS browser and display something else.
If the app is installed it will handle the URL and open, otherwise the browser will follow the link and the redirect and the Play Store app will open to handle the Play Store URL to your app.
Related
I would like to create a button on my PWA (which could run on an Android or an iOS device) which opens another particular application installed on a device (in this case, the app "VerificaC19", which is needed to verify a Green Pass certification.
Is there any Javascript/PHP code I could use to create a button in the PWA running on the browser which automatically opens the application?
This seems to be answered here for iOS.
You need to know the URL scheme of the app. Specific to iOS and Android there can be different URL Schemes registered with the target app.
I'd like to have a single 'Get App' link that auto-detects the user's device type and browser and directs to the appropriate location (iTunes, Google Play, or website sign-up). I am currently using Onelink.to, but it has the following limitations:
if you're on iOS using a non-Safari browser (like Chrome) you end up looking at a bunch of raw JSON because it doesn't know to launch the App Store app. In this case, I'd prefer to direct to the iTunes website or better yet, deep link into the App Store app.
if using the link on your own site and a user is on a device that redirects to a different page of your own website, it complicates setting up event-based goals in Google Analytics
Are there any good JavaScript solutions that handle the App Store redirect while excluding this action on browsers that don't support the iTunes headers?
Thanks!
You can use javascript navigator.userAgent and parse it to detect the device. Then just generate the link according to it.
Here is an example for ios detection:
Detect if device is iOS
I am working on a mobile website. We are showing a default screen on mobile website with 2 options.
1. Open in app
2. Continue to mobile site
now I have to check when user chooses Open in App, if App is already installed on mobile, open App.
If not go to play store.
Right now it is going to play store anyway.
How can I verify this, please suggest.
You can register an intent filter for a specific URI in the manifest. Whenever the URI is resolved by the system (for example when you click on it in the browser) you application would be notified and could start up. See also this so entry. But that does not handle the automatic redirect to the play store if the app is not installed. Maybe deep linking could do the job for you. This talk may also be relevant for deep linking.
I create 'iframe' element, use the http scheme to open an app on Android Device, it works fine if the app is installed.
When the app is not installed, I use setTimeout function setting window.location = marketurl,
it will open market, and it works fine on Android Browser, but it doesn't work on chrome 25+.
I only see an error message in my browser.
What should I do?
I believe there are some new changes to the functionality in Chrome for Android v. 25 and later. You may need to implement Intent. This is created to prevent unsafe app open from the browser.
Here is one example from Google Chrome for developers that will open the Zxing barcode scanner app.
Take a QR code
Reference: https://developer.chrome.com/multidevice/android/intents
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.
I am using an hybrid android app from geyser.
I want to inform the user about the possibility to download this app, if he enters the mobile version of my website. the thing is, in the app runs a browser which views almost the same content as the mobile website.
how can I detect with JS if I am running in the App-Browser and not on the normal Browser?
I don't want to show the download Link of the App in the App.
Thanks
What you could do is have a javascript function on your page like
setAndroidApp=function(){
isAndroidApp=true;
}
and then, when you load your site through the android version (assuming you're using the Android WebView class ), you could make the function run when loading the page in the following manner
webview.loadUrl("javascript:setAndroidApp()");
in which case, you'd have isAndroidApp set to true for the rest of your code if it's seen from the android app.