2

Ihave an app that handles a custom URL scheme (Myapp://). When someone comes to a web page that has some Myapp:// content, we need to redirect them to the store if they don't have our app installed.

  • here you can see good solution for your problem. http://stackoverflow.com/questions/12856773/detect-if-android-app-has-been-installed-on-the-device-using-a-mobile-web-page – Venkat Mar 23 '16 at 14:55

4 Answers4

2

In android you can use Intents as url to open your app or redirect to google play if application not installed.


i need to do that from java script

You can change location like this:

window.location.href = "intent://test#Intent;package=com.test.app;end;";
User9123
  • 23
  • 1
  • 4
  • thnks, but i'm using javascript , i need to do that from java script –  Mar 23 '16 at 11:07
0

For android, you need to mention the package name inside the url scheme like package=com.XYZ.ABC and then the android system will handle itself and open the play store if app is not present on the device. I'm not aware for IOS.

Jarvis
  • 503
  • 2
  • 5
  • 17
0
boolean installed = appInstalledOrNot("your package name");

if(!installed) 
{
  final String appPackageName = yourpackagename for the app to be installed; 
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?      id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW,      Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
  • thnks, but i'm using javascript , i need to do that from java script –  Mar 23 '16 at 11:07
  • are you trying to redirect to open in browser or installed playstore/appstore app .. ?? i know javascript also .. – priyanka morisetti Mar 23 '16 at 11:11
  • i'm coding in javascript imean i have a wab page, so when I scan the QR code, i redirecte immediatly to the app whiche installed in my smartphone thats okk!! but the probleme now, suppose that app doesn't installed in the smartphone so, the final user must redirect to the store, deponds which platform the user uses –  Mar 23 '16 at 11:16
-2

I've read your question very very thoroughly again. I hope I understand you correctly now:

  • you have an app
  • you have a web-page
  • if someone opens the web-page and they have your app installed, the app is launched?!
  • if someone opens the web-page and they don't have your app, they should be forwarded to the according appstore?!

For the last case: When you are using javascript, you should be able to check for the device type (with jQuery) and then do something like:

window.open('https://play.google.com/store/apps/details?id=' + yourPackageName);

see: redirect to appstore or google play

Community
  • 1
  • 1
Sunny Onesotrue
  • 152
  • 3
  • 13