Drag and Drop Restrictions

In iOS 11, drag and drop is enabled by default for certain UI elements (text views, text fields, ...). I was wondering, how to prevent drag and drop from a source app that may contain sensitive data.


In WWDC 2017 - Session 203 it was noted that Apple "wanted our source applications to have the ability to restrict access to their data to just their app, to other apps developed by the same team, and then, of course, to all apps on the system.“ However, so far, I couldn't find any information on this.


Is there a simple configuration switch to restrict access to the source app only, or what is the recommended way to accomplish this?


Bonus question: In a MDM enterprise enviorment, does iOS 11 drag & drop prevent dragging items from managed sources to unmanaged destinations, and vice versa (given that allowOpenFromManagedToUnmanaged is set to false)?

Replies

Hey,


there is indeed a function to restrict the access to the source app only. In your UIDragInteractionDelegate you simply have to implement the method: dragInteraction(_:sessionIsRestrictedToDraggingApplication:) and return true. There is also a similar function for the UITableViewDragDelegate and the UICollectionViewDragDelegate.


Best,
Klemens

Thanks for your reply. I already noticed this delegate, but was still wondering, if there is no easier way to disable DnD for the entire app (instead of manually treating each element type)?


In order to disable the default DnD behavior (UITextFields, UITextViews, etc.) you'd recommend to subclass each element type and to implement the respective delegate methods for this?