简体   繁体   English

从网站打开 UWP 应用

[英]Open UWP app from website

Let's start with the background.让我们从背景开始。 We are building an app on iOS / Android / Windows where we'll use Firebase Dynamic Links to share content between users (the link looks like this: https://xya.app.goo.gl?link=.. .).我们正在 iOS / Android / Windows 上构建一个应用程序,我们将在其中使用 Firebase 动态链接在用户之间共享内容(链接如下所示: https : //xya.app.goo.gl? link =.. .)。 On iOS & Android this can launch the app if it is installed or open Play / Store if not installed yet.在 iOS 和 Android 上,如果已安装,则可以启动该应用程序,如果尚未安装,则可以打开 Play/Store。 This also has the advantage of a graceful fallback to our web app.这也具有优雅回退到我们的网络应用程序的优势。

Now this isn't natively supported on Windows.现在,Windows 本身不支持此功能。 There are only following options:只有以下选项:

  • Custom URI Schemes (eg app://some-link).自定义 URI 方案(例如 app://some-link)。 Not usable because there would be no graceful fallback to our web不可用,因为我们的网络不会有优雅的回退
  • URI handler - since Anniversary Update app can register a handler for regular http URI. URI 处理程序 - 因为周年更新应用程序可以为常规 http URI 注册一个处理程序。 Again not usable because we don't own the domain http://goo.gl which is used for the link再次无法使用,因为我们不拥有用于链接的域http://goo.gl

This leads me to only one viable option left - on our web app, detect if user is on Windows.这让我只剩下一个可行的选择 - 在我们的网络应用程序上,检测用户是否在 Windows 上。 If he is, check if the app is installed and launch it or the Windows Store to let user download it.如果是,请检查该应用程序是否已安装并启动它或 Windows 应用商店以让用户下载它。

Is my thinking correct?我的想法正确吗? If so, how do I launch my app / Store from the web app?如果是这样,我如何从网络应用程序启动我的应用程序/商店? It should be possible, it works with Store (when you navigate to Windows Store - eg https://www.microsoft.com/en-gb/store/p/ ... - it opens the store app)它应该是可能的,它适用于商店(当您导航到 Windows 商店时 - 例如https://www.microsoft.com/en-gb/store/p/ ... - 它会打开商店应用程序)

Any ideas?有任何想法吗? I need two thinks - detect if app is installed & launch it我需要两个想法 - 检测是否安装了应用程序并启动它

If you click on a URI with a custom URI scheme, but there is no registered app in Windows for that URI scheme, it will ask to download a supported app from the Store.如果您单击具有自定义 URI 方案的 URI,但在 Windows 中没有该 URI 方案的注册应用程序,它将要求从应用商店下载支持的应用程序。 You can test it with a link to eg app://test (linking to non-http(s) websites does not seem to work in StackOverflow, but you can create a simple demo HTML for that).您可以使用指向例如 app://test 的链接对其进行测试(链接到非 http(s) 网站在 StackOverflow 中似乎不起作用,但您可以为此创建一个简单的演示 HTML)。

<html>
<body>
    <a href="app://test">Test link</a>
    <a href="twitter://">Open twitter</a>
</body>
</html>

If an app to handle that URI scheme is installed it will open it, so you need to detect if you're on Windows 10 basically (which is an HTML/JS question I think).如果安装了处理该 URI 方案的应用程序,它将打开它,因此您需要检测您是否基本上使用的是 Windows 10(我认为这是一个 HTML/JS 问题)。 And I think this is also what the Windows Store does basically.我认为这也是 Windows 应用商店的基本工作。 Because it does not open the Store app for every app (eg not for WP8.1 apps if you're on a W10 desktop), that's why I'd guess there is a check on the website.因为它不会为每个应用程序打开商店应用程序(例如,如果您使用 W10 桌面,则不会为 WP8.1 应用程序打开),这就是为什么我猜网站上有一个检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM