简体   繁体   English

自定义URL方案参数

[英]Custom URL Scheme Parameters

When defining the custom URL scheme for my app there are 3 keys that I need information about: 在为我的应用定义自定义URL方案时,我需要以下3个键的信息:

  1. CFBundleTypeRole aka Document Role CFBundleTypeRole aka文件角色
  2. CFBundleURLName aka URL identifier CFBundleURLName又名URL标识符
  3. CFBundleURLSchemes aka URL Schemes CFBundleURLSchemes又名URL方案

I can see, if I just define CFBundleURLSchemes to be myapp the app is launching fine with an URL as myapp:// . 我可以看到,如果仅将CFBundleURLSchemes定义为myapp该应用程序启动正常,URL为myapp:// Questions are: 问题是:

  1. Is the URL identifier there only to make my scheme unique? URL标识符是否仅使我的方案唯一? How does it do that? 它是如何做到的? If I have same scheme myapp defined in 2 apps, and I call myapp:// can I specify which one I want to call by calling myapp://<URL Identifier> ? 如果我在2个应用程序中定义了相同的方案myapp ,并且我调用myapp://可以通过调用myapp://<URL Identifier>指定要调用的方案? Edit: What does this URL Identifier actually do? 编辑:此URL标识符实际上是做什么的? Does it only give a name to url? 它只给网址起一个名字吗? How it is used? 如何使用?
  2. The Role defines the level of permission which is None, Viewer or Editor, I am not sure what level of permission my app has on the launched app as I have not defined anything. 角色定义的权限级别为“ None, Viewer or Editor,我不确定我的应用程序对启动的应用程序的权限级别,因为我没有定义任何内容。 I would like to know what is the default permission when the CFBundleTypeRole is not defined. 我想知道未定义CFBundleTypeRole时的默认权限是什么。

to 1: 至1:

A protocol is not guaranteed to be unique. 不能保证协议是唯一的。 There is no parameter you can define that will open app1 or app2. 您没有定义可以打开app1或app2的参数。 If two apps use the same scheme it is undefined what happens 如果两个应用程序使用相同的方案,则不确定

to 2: 至2:

the role is irrelevant for the most part BUT mandatory : 该角色在大多数情况下是无关紧要的,但必选

  • editor = launched because they can R/W files identified by the same 编辑器=已启动,因为它们可以读写同一文件标识的文件
  • viewer = can only read and display viewer =只能读取和显示

Ad 1) 广告1)

According to Apple documentation they don't give much info about the identifier and why it is needed or where it is used. 根据Apple文档,他们没有提供太多有关标识符以及为什么需要标识符或在何处使用标识符的信息。 They only say that it should be unique. 他们只说它应该是唯一的。

Also if more than one app specify the same url scheme, then the outcome is unpredictable. 同样,如果多个应用程序指定了相同的url方案,那么结果将是不可预测的。

See URL identifier and URL scheme 请参阅URL标识符和URL方案

Ad 2) 广告2)

The Role flag isn't used by iOS. iOS不使用Role标志。

See In Xcode, under Info tab, what's Role for in URL Types section? 请参阅在Xcode中“信息”选项卡下的“ URL类型”部分中的作用是什么?

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

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