iPhone / iPad URL自定义方案打开文件 [英] iPhone/iPad URL Custom Scheme to open a file

查看:370
本文介绍了iPhone / iPad URL自定义方案打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在使用iPad的Safari浏览器时拦截某些文件。您可能知道,Safari无法下载文件,因此Safari可以发送我的应用程序这些文件链接。

I'm trying to intercept some kind of files while using iPad's Safari browser. As you probably know, Safari can't download files, so it would be useful Safari to send my app those files links.

正如我在iPhone / iPad开发人员文档,您可以添加一个URL自定义方案来处理一些特殊的协议(例如youtube:或tel:打开youtube或拨一个号码),但是我不想处理一个特殊的协议,而是一种特殊的文件使用常规http / https协议。

As I've read in the iPhone/iPad developer documentation, you can add an URL Custom Scheme to handle some special protocols (like youtube: or tel: to open either youtube or dial a number), but I don't want to handle a special protocol but a special kind of file using regular http/https protocol.

如果URL方案可能是这样的:

It would be nice if the URL scheme could be something like:

http://*.zip

我已经尝试搜索一些文档,我甚至尝试在模拟器,但我无法设计一个适当的URL方案来捕获一个zip文件。

I have tried to search some docs, and I've tried even in the simulator, but I cannot be able to design a proper URL Scheme to catch a zip file.

我可以处理这种情况使用CFBundleURLTypes和CFBundleURLSchemes参数到我的应用程序.plist?

Can I handle this situation using the CFBundleURLTypes and the CFBundleURLSchemes parameters into my application .plist ?

如果你不能使用这种方法,有没有另一种方法来实现?

If you cannot do that using this method, is there another way to achieve this?

谢谢;)

推荐答案

不能这样做。尝试像您的应用程序打开zip文件的 zip:// [路径到zip文件] 的自定义url方案。当用户想要打开zip文件时,他们只需将http(s)更改为zip。在 CFBundleDocumentTypes 中注册您的文件类型只会影响邮件中的打开方式操作列表,以及GoodReader等应用程序。

Can't do that. Try a custom url scheme like zip://[path to zip file] that opens the zip file with your app. When a user wants to open a zip file, they just change the http(s) to zip. Registering your file type in CFBundleDocumentTypes will only affect the Open With... action sheets in Mail and apps like GoodReader.

这篇关于iPhone / iPad URL自定义方案打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆