2

I am working on cordova app in which i am able to launch my app from web page is it is installed.

<a href="mycoolapp://>Launch my app</a>

how do i generate a link so that it would redirects me to followings

  1. To App if app is installed.

  2. To google play installation page if app is not installed.

ashishkumar148
  • 935
  • 10
  • 26
  • possible duplicate of [How to check if an app is installed from a web-page on an iPhone?](http://stackoverflow.com/questions/13044805/how-to-check-if-an-app-is-installed-from-a-web-page-on-an-iphone) – Mikhail Radionov Sep 11 '15 at 10:20
  • no platforms are different hence both require different solutions – ashishkumar148 Sep 11 '15 at 12:10

4 Answers4

1

You can check the app is installed or not using the following plugin

https://github.com/ohh2ahh/AppAvailability#old-approach-appavailability--030

After that using this to achieve your needs.

appAvailability.check(
    'com.example.com', // Your Package Name
    function() {           // Success callback
        //your app is installed 
        //launch your app
    },
    function() {           // Error callback
        //app is not installed
        //go to google play store 
    }
);
iam batman
  • 4,320
  • 10
  • 45
  • 94
  • 1
    how to integrate the plugin with html which contains link of app. this is cordova plugin which can be easily integrated in cordova app but i am trying to resolve from web. – ashishkumar148 Sep 11 '15 at 09:41
  • Yeah, I have to use it in web page and from that i have to route it to app or play store accordingly. I am unable to find a proper way to do that. – ashishkumar148 Sep 11 '15 at 13:01
1

deep-link.js is a very nice and easy to use library that allows to do what you want. In your case you would need to include the lib on your web page and change your link as follows:

<a href="http://yourfallbackwebsite.com"
   data-app-ios="mycoolapp://"
   data-store-ios="your_ios_app_id"
   data-app-android="mycoolapp://"
   data-store-android="your_android_app_id">
  Launch my app
</a>

Refer to the website for more details/examples.

severin
  • 9,689
  • 1
  • 36
  • 39
0

If you detect that a user has your app already, you'll need to make sure both your iOS and Android app (on cordova) properly register for the URI scheme "mycoolapp://". Set window.location to your URI scheme, taking note that certain browsers require some extra work.

If this times out, or returns an error, then you know the person on your website doesn't have your app. You can then route them to the Play / App store.

There are open-source services (full disclosure, employee of one currently), that package this all into one neat bundle. Check out Branch.

Sahil Verma
  • 517
  • 2
  • 5
0

I don't have any development experience in cordova. My below answer is purely based on recent experiments on Android.

It turns out that you are aiming to achieve the following responses:

  1. The app is installed: In this case, the control should move to the app, hence, the app should be launched.

  2. The app is not installed: The user should be directed to the Google Play to install the same 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.

From what I experimented, this URL is understood by the browser and it redirects you to the App based on the package name and the deep-link scheme. Else it takes you to the Google Play.

PS: The Google Play makes a broadcast to the app. So make sure you receive the broadcast in a receiver.

Shivam Dixit
  • 288
  • 4
  • 12