xcode 具有相同 URL Scheme 的多个应用程序 - iOS

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

Multiple apps with the same URL Scheme - iOS

iosxcodeurl-scheme

提问by Albert Renshaw

So for my new app I'm having a URL scheme so that people can launch my app from another app or from a website... "myapp://" ... So what happens if there is another app in the AppStore that has the same URL scheme as mine? Or if someone tries to steal my URL Scheme?

所以对于我的新应用程序,我有一个 URL 方案,以便人们可以从另一个应用程序或网站启动我的应用程序......“myapp://”......那么如果 AppStore 中有另一个应用程序会发生什么有和我一样的 URL 方案吗?或者如果有人试图窃取我的 URL Scheme?

采纳答案by rmaddy

If two apps register the same custom URL scheme, it is undefined which app will actually be launched. One will be launched but there is no way to know.

如果两个应用程序注册了相同的自定义 URL 方案,则未定义实际启动哪个应用程序。一个将推出,但没有办法知道。

Here's a real kicker. If you have two apps on your device with the same URL scheme, and you delete the one that actually gets launched, the other one will not get launched by the URL without rebooting the iOS device.

这是一个真正的踢球者。如果您的设备上有两个具有相同 URL 方案的应用程序,并且您删除了一个实际启动的应用程序,则在不重新启动 iOS 设备的情况下,另一个应用程序将不会通过该 URL 启动。

Your best solution is to ensure your custom URL scheme is not trivial so there is little chance another app will have the same scheme.

您最好的解决方案是确保您的自定义 URL 方案不是微不足道的,因此其他应用程序具有相同方案的可能性很小。

回答by Dustin

According to the Apple docs:

根据苹果文档:

If multiple third-party applications register to handle the same URL scheme, it is undefined as to which of the applications is picked to handle URLs of that type.

如果多个第三方应用程序注册以处理相同的 URL 方案,则未定义选择哪个应用程序来处理该类型的 URL。

Exact quote from the Apple docs, for 8 consecutive years:

连续 8 年准确引用 Apple 文档:

Note: If more than one third-party app registers to handle the same URL scheme, there is currently no process for determining which app will be given that scheme.

注意:如果有多个第三方应用程序注册处理相同的 URL 方案,目前没有确定哪个应用程序将获得该方案的过程。

Sources:

资料来源:

As of September 2019, this part of the documentation was removed from the Apple website. The closest related document may now be Register Your URL Scheme.

截至 2019 年 9 月,这部分文档已从 Apple 网站上删除。最接近的相关文档现在可能是Register Your URL Scheme

回答by Bosh

Updated for 2016

2016 年更新

Apple's policy has changed since 2012. Today they indicate that multiple apps will not be allowed to register for the same scheme. Registration time is a much cleaner place to address contention than runtime, since it avoids the security issues discussed it other answers.

Apple 的政策自 2012 年以来发生了变化。今天他们表示将不允许多个应用程序注册同一个方案。注册时间比运行时更能解决争用问题,因为它避免了其他答案中讨论的安全问题。

Note: If more than one third-party app registers to handle the same URL scheme, there is currently no process for determining which app will be given that scheme.

注意:如果有多个第三方应用程序注册处理相同的 URL 方案,目前没有确定哪个应用程序将获得该方案的过程。

Source:https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW1

来源:https: //developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW1