How to transfer files from one application to another on the same iOS device?

I am writing an iOS application that converts a file saved by another application on the same device to a different format. How to transfer files from one application to another on one device? Please note that the files are non-text files.

+7
source share
2 answers

UIDocumentInteractionController is your friend.

It basically works as follows:

  • Applications 1 are registered as capable of handling XYZ files
  • Appendix 2 implements the UIDocumentInteractionController and will provide users with the ability to "send the file to App1" (I believe this should be activated by the user).
  • Appendix 1 implements -(BOOL)application:openURL:sourceApplication:annotation: and processes the transferred file, which will be saved in your Documents/Inbox directory. From there, you can copy the file to another location, and then process it, making sure that you have cleared by getting rid of the original stored in the inbox.

Class reference here

Document Interaction Programming Guide Available Here

+16
source

If you are developing both applications, you can store general information in the keychain if your package identifiers match the same package seed identifier. See here for more details. Of course, if you make both applications, you can use a URL scheme to pass in base64 encoded data.

Update: as shown below, the UIDocumentInteractionController is great, but only available for version 4.2 and higher, so you want to cut out the bulk of your users if you want to use it.

+3
source

All Articles