willBeginSendingToApplication not called when open EverNote or any other extention

我只是一个虾纸丫 提交于 2020-01-03 05:39:05

问题


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

is called.

In this method I can check whether to allow for chosen app or not.

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.


回答1:


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.

  • Always use UIDocumentInteractionController instead of UIActivityViewController

  • Whenever UIDocumentInteractionController is opened reinit and set the URL to dummy content

  • Conform to UIDocumentInteractionControllerDelegate and check the application parameter in willBeginSendingToApplication against your whitelist

  • If application is part of the whitelist then change the value of controller.url to the correct content

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.

You can also check out this article for private APIs to hide third-party apps and extensions, mostly in UIActivityViewController:

How to exclude Notes and Reminders apps from the UIActivityViewController?

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.



来源:https://stackoverflow.com/questions/34395034/willbeginsendingtoapplication-not-called-when-open-evernote-or-any-other-extenti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!