2

I have such code (angular.js) to detect mobile platform and redirect to native-app (if not installed - then it redirect to market):

$scope.isMobile = {
  Android: function() {
      return navigator.userAgent.match(/Android/i);
  },
  BlackBerry: function() {
      return navigator.userAgent.match(/BlackBerry/i);
  },
  iOS: function() {
      return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  },
  Opera: function() {
      return navigator.userAgent.match(/Opera Mini/i);
  },
  Windows: function() {
      return navigator.userAgent.match(/IEMobile/i);
  },
  any: function() {
      return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  }
};


if($scope.isMobile.Android()){
  $timeout(function() {
    $window.open(
      'https://play.google.com/store/apps/details?id=***&referrer=' + $routeParams.inviteId,
      '_self'
    );
  }, 500);
}

if($scope.isMobile.iOS()){
  window.location = '***://?referrer=' + $scope.inviteId;
  setTimeout("window.location = 'https://itunes.apple.com/us/app/****/id***';", 1000);
}

and now i have one question:

how to do this on windows phone platform?

do windows phone recognize themselves is app installed or not (as android do) or i need to go as iOS do?\ also how can i pass parameter to application (like android do)?

brabertaser19
  • 5,678
  • 16
  • 78
  • 184
  • You might want to consider another approach, namely associate your application with an URL scheme (example; http://app.yourdomain.com), which would fire up the application if installed. If not, it would follow that link, and on that page you can redirect them to the appropriate app store. This works in both Android and IOS, and probably WP as well. This is how imdb and youtube does it, for example. – jishi Oct 05 '15 at 08:52
  • This question explains it http://stackoverflow.com/questions/525063/android-respond-to-url-in-intent/525086#525086 – jishi Oct 05 '15 at 09:03
  • @jishi all works perfect on Android & iOS. So i do not need to change any thing. BTW: android has this schema already. My question is about WP! – brabertaser19 Oct 05 '15 at 09:06

1 Answers1

0

The link to app on Windows Phone is: http://windowsphone.com/s?appId={GUID} This opens the page in browser and immediately redirects to the store app.

This document also mentions ms-windows-store://pdp/?ProductId={ID} to open the store directly if you are certain about the platform you're on. It will work on Windows 10, but may be problematic on older platforms.

Note that the {GUID} and {ID} in those links are differnt numbers.

If you are affiliated with the Windows Phone app developer, you can request to implement the URI association feature. Then you can use the custom implemented uri and pass parameters to the app. If the app is not installed, as far as I can remember, the user will be asked if they want to look for apps associated with this uri in the store.

lisp
  • 4,138
  • 2
  • 26
  • 43
  • It will redirect to the store anyway, the only difference is that text on the main button will be "show" instead of "install". – lisp Oct 05 '15 at 09:09
  • @brabertaser1992 I edited the answer and added the info about the uri associations. – lisp Oct 05 '15 at 09:16