从WEB(js)重定向到Windows Phone应用程序(未安装时 - 上市)

时间:2015-10-02 13:43:37

标签: javascript angularjs windows-phone-8

我有这样的代码(angular.js)来检测移动平台并重定向到native-app(如果没有安装 - 然后重定向到市场):

$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);
}

现在我有一个问题:

如何在windows phone平台上执行此操作?

做Windows手机识别自己是应用程序安装与否(如安卓做)或我需要像iOS那样做? 我怎样才能将参数传递给应用程序(如android do)?

1 个答案:

答案 0 :(得分:0)

Windows Phone上的应用程序链接是: http://windowsphone.com/s?appId={GUID} 这将在浏览器中打开页面并立即重定向到商店应用程序。

如果您确定自己所处的平台,

This document还会提及ms-windows-store://pdp/?ProductId={ID}直接打开商店。它可以在Windows 10上运行,但在旧平台上可能会出现问题。

请注意,这些链接中的{GUID}和{ID}是不同的数字。

如果您是Windows Phone应用开发者的附属机构,则可以请求实施URI association feature。然后,您可以使用自定义实现的uri 并将参数传递给应用。如果未安装该应用程序,据我所知,将询问用户是否要在商店中查找与此uri相关联的应用程序。