打开EverNote或任何其他扩展时,不会调用willBeginSendingToApplication [英] willBeginSendingToApplication not called when open EverNote or any other extention
问题描述
我有一项功能可以在iPhone和iPad应用的其他应用中打开文档。
此外,还设置一个标志是否允许此操作。很少有应用程序可以列入白名单。
I have a feature to open docs in other apps from iPhone and iPad app. Also a flag is set whether to allow this action or not. Few apps can be white listed.
当选择任何应用程序打开文档时
When any app is chosen to open doc
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
被叫。
在这种方法中,我可以检查是否允许选择的应用程序。
In this method I can check whether to allow for chosen app or not.
问题是注意,Evernote我们有两个选项1-它的扩展名2-开放。
以上方法被调用为2选项。
但扩展是直接启动的。
Issue is for Note, Evernote we get two options 1- its extension 2- Open in. Above method is called for 2 option. But extensions are launched directly.
我没有找到任何其他委托方法。
I din't found any other delegate method called for this.
推荐答案
希望你能找到一些东西,但我的组织面临着类似的问题,我们合作的MDM没有一个简单的解决方案。我们决定使用以下方法。
Hopefully you figured something out, but my org faced a similar issue and the MDMs we work with don't have an easy solution. We've decided on the following approach.
-
始终使用
UIDocumentInteractionController
代替UIActivityViewController
每当 UIDocumentInteractionController
是打开reinit并将URL设置为虚拟内容
Whenever UIDocumentInteractionController
is opened reinit and set the URL to dummy content
符合 UIDocumentInteractionControllerDelegate
并检查应用
中的参数willBeginSendingToApplication
针对白名单
Conform to UIDocumentInteractionControllerDelegate
and check the application
parameter in willBeginSendingToApplication
against your whitelist
如果 application
是白名单的一部分,然后将 controller.url
的值更改为正确的内容
If application
is part of the whitelist then change the value of controller.url
to the correct content
这种方法的缺点是只有open-in才能工作(扩展将始终获得虚拟内容)并且用户体验不是很好。但是,如果您正在构建企业应用程序并且必须防止数据泄漏,那么这可能是最安全的方式。
The downsides of this approach are that only open-in will work (extensions will always get dummy content) and the user experience isn't great. But if you're building an enterprise app and must prevent data leakage then this is probably the safest way to go.
您还可以查看本文以获取私有API隐藏第三方应用和扩展程序,主要在 UIActivityViewController
:
You can also check out this article for private APIs to hide third-party apps and extensions, mostly in UIActivityViewController
:
如何从UIActivityViewController中排除Notes和Reminders应用程序?
不幸的是,它的工作方式似乎在iOS 8和9之间发生了变化,并且再次变为10,所以它不是最佳的。我建议传递虚拟内容。
Unfortunately the way this works seems to have changed between iOS 8 and 9, and again with 10, so it's not optimal. I recommend passing dummy content.
这篇关于打开EverNote或任何其他扩展时,不会调用willBeginSendingToApplication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!