iOS 通用链接 App Store 重定向

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36045003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:42:32  来源:igfitidea点击:

iOS Universal Link App Store redirect

iosios-universal-links

提问by Rodrigo.C

I have universal links working correctly, when the app is installed I see how the link opens the app, and when it's not installed opens the url in safari.

我的通用链接工作正常,安装应用程序后,我会看到链接如何打开应用程序,未安装时会在 safari 中打开 url。

Actually what I would like to do is to redirect and go to the app store, so users can download the app directly. Im going to include a redirect on the html file, because I know universal links don't support redirects a the http server config level (anyway I think this is for the manifest file only, apple-apps-site-association)

其实我想做的是重定向并转到应用程序商店,以便用户可以直接下载应用程序。我将在 html 文件中包含重定向,因为我知道通用链接不支持重定向 http 服务器配置级别(无论如何我认为这仅适用于清单文件,apple-apps-site-association)

Anyone can confirm if this is the right way to do it, or the only way to do it? I don't like the idea to open safari first, load my html (with the redirect only) and then go to the store. Looks like there's no easier way to do it.

任何人都可以确认这是正确的方法,还是唯一的方法?我不喜欢先打开 safari,加载我的 html(仅使用重定向)然后去商店的想法。似乎没有更简单的方法可以做到这一点。

回答by Alex Bauer

You're right: server-side redirects aren't allowed for the apple-app-site-associationfile. However, I believe once the user opens a Universal Link and (assuming the app is notinstalled) lands on the URL, all options are on the table (server-side, or otherwise).

您说得对:该apple-app-site-association文件不允许服务器端重定向。但是,我相信一旦用户打开通用链接并且(假设应用程序安装)登陆 URL,所有选项都在表上(服务器端或其他)。

If the page on the other end of your Universal Links URL contains an instant JS redirection to your app's App Store page, that should work just fine. Something like this:

如果通用链接 URL 另一端的页面包含到应用程序 App Store 页面的即时 JS 重定向,那应该可以正常工作。像这样的东西:

window.location = 'itms-apps://itunes.apple.com/us/app/imdb-movies-tv/id342792525'

But yes, no matter how you do it, Safari is still going to open. It'll flash past so quickly that the user likely won't even notice. Here's a real-time recording I just made of the Branch.iodeep linking service's demo app doing exactly this process:

但是是的,不管你怎么做,Safari 仍然会打开。它会闪过如此之快,以至于用户可能甚至都不会注意到。这是我刚刚对Branch.io深度链接服务的演示应用程序执行此过程的实时记录:

enter image description here

在此处输入图片说明

回答by Almo

From here: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html

从这里:https: //developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html

"When you support universal links, iOS 9 users can tap a link to your website and get seamlessly redirected to your installed app without going through Safari. If your app isn't installed, tapping a link to your website opens your website in Safari."

“当您支持通用链接时,iOS 9 用户可以点击指向您网站的链接并无缝重定向到您已安装的应用程序,而无需通过 Safari。如果您的应用程序未安装,则点击指向您网站的链接会在 Safari 中打开您的网站。 ”

You're not doing it wrong, that's just how they work.

你没有做错,这就是他们的工作方式。