3

I have an iOS app that I want to be able to send and receive instances of its own file type. The flow would be:

  • User 1 selects a Share function in the app. This generates a file of my type (say, file.myextension) and shares it using a UIActivityViewController. They send it somehow to User 2 (AirDrop, email, whatever).
  • User 2 receives the file and opens it. The system offers to open it using my app.

I've got the first part working. I can generate file.myExtension and give the UIActivityViewController a file URL to it. This shows up correctly in AirDrop on user 1's device, and I can transfer the file using AirDrop or email or whatever. But the receiving device refuses to show my app as an option to open the file.

I have tried:

  • Declaring Exported and Imported UTIs and a Document Type as per this Apple Q&A. I've triple-checked that all the IDs are the same and all the plist keys are spelled correctly.
  • I've tried both an Exported and Imported UTI alone (with a Document Type). This article seems to say that the Imported one is what I want if I want to open a file type. This SO answer says that registering a type I own and want to open means I just want Exported. Neither on its own worked.

My question: what do I have to do to be able to open a file extension that I own on iOS? Do I define both Imported and Exported UTIs, along with a Document Type? Just one of exported or imported? Any unexpected required attributes?

Community
  • 1
  • 1
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145

2 Answers2

1

The CFBundleDocumentTypes key is what you need. It should be an Array, and each item in the array should be a Dictionary. Each Dictionary should contain the following keys:

CFBundleTypeIconFiles (Array of Strings)

CFBundleTypeName (String)

CFBundleTypeRole (String)

LSHandlerRank (String)

LSIsAppleDefaultForType (Boolean)

LSItemContentTypes (Array of Strings)

Here is what it looks like for my application (stuff blacked out to avoid revealing my company's identity):

enter image description here

Community
  • 1
  • 1
Jeff Loughlin
  • 4,134
  • 2
  • 30
  • 47
0

Figured it out. One key detail not explicit in the docs is that the last part of the types in the Document Type section has to match the file extension you choose.

Tom Hamming
  • 10,577
  • 11
  • 71
  • 145