Jam*_*rch 5 mobile-safari ios uidocumentinteraction launch-services
在iOS Safari中单击“共享”按钮时(通过工具栏或长按链接),我希望我的应用程序显示为“在...中打开”选项(例如,“在新闻中打开” ”),以便我的应用(这是另一种网络浏览器)可以打开Safari共享的任何内容http://
或https://
URL。
我已经在苹果info.plist
文件中注册了文档类型“ URL”(我相信这是正确的类型,如果此假设是错误的,请更正!),我CFBundleDocumentTypes
可以从Apple的“注册应用程序支持的文件类型”文档中猜到,他们的技术问答以及与之相关的StackOverflow帖子1 2 3:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>appIcon320</string>
<string>appIcon64</string>
</array>
<key>CFBundleTypeName</key>
<string>URL</string>
<key>CFBundleTypeRole</key>
<string>Editor</string> <!-- Note: I have also tried 'Viewer' -->
<key>LSHandlerRank</key>
<string>Owner</string> <!-- Note: I have also tried 'Default' -->
<key>LSItemContentTypes</key>
<array>
<string>public.url</string>
</array>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
我也用以下代码编写了这个存根方法AppDelegate.swift
(尽管我认为实际上与使我的应用程序显示为“打开方式...”选项的第一阶段的成功无关):
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {opening-in-app-getting-uiapplicationlaunchoptionsurlkey-from-launchoptions?rq=1
print("Received URL: \(url); from source: \(options[.sourceApplication] ?? "nil"); with annotation: \(options[.annotation] ?? "nil")")
return true
}
Run Code Online (Sandbox Code Playgroud)
...但是,我的应用程序仍然没有显示为“在...中打开”选项。我必须添加应用程序图标已正确与应用程序捆绑在一起,并且该info.plist
文件在Xcode中可以正常打开,因此我可以确认它没有损坏。
所以我有三个问题:
长按链接并点击“共享...”按钮,Safari共享的文档类型是否确实是“ URL”?
按下Safari工具栏上的图形按钮(令人迷惑又称为“共享”按钮)后,Safari是否与以前一样共享文档类型“ URL”?
我是否已CFBundleDocumentTypes
正确编写URL类型的文档?或者,如果Safari共享其他内容,它是什么(以及我应该怎么写)?
归档时间: |
|
查看次数: |
447 次 |
最近记录: |