用法去下,只要在Info.plist中配置上对应文件类型就行,如图(以PDF文件作为示例)
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>com.adobe.pdf</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
</array>
</dict>
</array>
添加完之后,然后微信里打开一个pdf并且点击上边的三个点看分享
你看我们的App出现在可选列表了,这一部分算是搞定了。然后就是我们需要处理点击我们App过后的处理
//直接在appDelegate里边这个方法里处理,url即选择文件的路径
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return true
}