ohh2ahh / AppAvailability

This Cordova / PhoneGap plugin allows you to check if an app is installed.
229 stars 116 forks source link

app available but not opening #32

Closed rolinger closed 8 years ago

rolinger commented 8 years ago

How can an app be opened? I have some apps that provide deeplink parameters, so I am passing those parameters into "deeplink" below....but other apps don't have deeplinks (that I am aware of), so how can I just get the app to launch?

On Android, I have the package name (not certain how to get it for iOS), and as best I can tell appAvailability.check is seeing the app installed, but its not able to open it.

two examples:
// works
var scheme = "com.ubercab" ;
var deeplink = "uber://" ;   // documented uber deeplink, uber app launches just fine
// does not work
var scheme = "com.tride.passenger" ; 
var deeplink = "tride://" ;  // not deeplink documented, "tride://" I made up, Tride app does not launch, but it is installed (and "alert" appears)...so what else can I define "deeplink" as to get the app to open?
  appAvailability.check(
    scheme,
    function() {
      // app is available
      var newWin = window.open(deepLink,'_system','location=no') ;
      errMgmt("index/externalApp",1021,"Deeplink: "+deepLink) ;
      if (newWin || newWin.closed) {
        alert(vendorID+ "does not have ability to be auto-opened, you will need to manually open the " +vendorID+ " app.") ;
        errMgmt("index/externalApp",1022,"Deeplink to "+vendorID+ " failed to open") ;
      }
    }, function () {
      // app is not available, open website link
      window.open(url,'_system','location=no') ;
      errMgmt("index/externalApp",1023,"Url: "+url) ;
    }
  );
ohh2ahh commented 8 years ago

Hi @rolinger

This plugin only checks if a specific app is installed. It can't be used for launching apps because I want to keep this plugin as simple as possible.

On iOS you can only launch an app when the target app supports an URL scheme (e.g. uber://). iOS 9 and iOS 10 require some extra work, which is described here. Without an URL scheme it's impossible launching other apps.

On Android you can launch an app with an URL scheme (if provided) or the app's package name (e.g. com.ubercab). You need to install another plugin if you want to launch apps via package names.