可以从网络链接启动 iOS 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5793992/
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-30 19:43:24  来源:igfitidea点击:

Possible to launch an iOS app from a web link

ioshyperlinkprotocols

提问by ima747

My app bounces the user out of the app into safari to do some web things (toying with using a webview but there are other concerns regarding layout, usage, re-launching the app, server errors, etc.). When they are done I would like a link on the final web page that lets them re-launch the app. I think this should be possible through a protocol implementation of some sort (such as href="myAppProtocol://relaunch") but I don't know how to go about implementing it properly.

我的应用程序将用户从应用程序中跳出到 safari 中来做一些网络事情(玩弄使用 webview 但还有其他关于布局、使用、重新启动应用程序、服务器错误等的问题)。当他们完成后,我想要一个最终网页上的链接,让他们重新启动应用程序。我认为这应该可以通过某种协议实现(例如 href="myAppProtocol://relaunch")来实现,但我不知道如何正确实现它。

[UPDATE] (can't answer my own question yet so editing here)

[更新](还不能回答我自己的问题,所以在这里编辑)

Stumbled across this just after posting (hours of looking and this is always how it comes together...) http://mobileorchard.com/apple-approved-iphone-inter-process-communication/

在发布后偶然发现了这个(看了几个小时,这总是如何组合在一起......)http://mobileorchard.com/apple-approved-iphone-inter-process-communication/

Using a URL type handler in your plist (as I suspected) you can declare that your app handles urls of that type (say "myAppProtocol"). iOS then launches your app and hands it the URL when it's touched in safari. What you do from there is up to you, I just need to launch so I don't take it any further, but you could grab the URL and parse it out for further passed information etc.

在您的 plist 中使用 URL 类型处理程序(正如我怀疑的那样),您可以声明您的应用程序处理该类型的 url(例如“myAppProtocol”)。然后,iOS 会启动您的应用程序,并在 safari 中触摸它时将 URL 传递给它。你从那里做什么取决于你,我只需要启动所以我不会再进一步​​了,但是你可以获取 URL 并解析它以获取进一步传递的信息等。

采纳答案by phi

I guess you found the answer already, but have a look at the docs as well: Using URL Schemes to Communicate with Apps.

我想您已经找到了答案,但也请查看文档:Using URL Schemes to Communicate with Apps