4

I would like to import vCards into my iOS app using the mail app. I have added public.vcard to my projects plist. If I try to open the vcard in another app using the UIDocumentInteractionController everything works as expected. However if I try to open the vCard in the mail app, the vCard is opened in the mail with no choice for my app. Is there a solution?

UPDATE: The plist entry for the vcard looks like

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>vCard</string>
        <key>LSHandlerRank</key>
        <string>Default</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.vcard</string>
        </array>
    </dict>
</array>
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
Peter
  • 83
  • 6
  • LSHandlerRank - Default might be the culprit. According to _"Information Property List Key Reference"_, " Default (default; this app doesn’t accept drops of files of this type). ". Also, your code appears to be incomplete, you are missing 'CFBundleTyperole' and 'CFBundleTypeIconFiles'. There is a pretty good summary here, [http://stackoverflow.com/questions/2774343/how-do-i-associate-file-types-with-an-iphone-application](http://stackoverflow.com/questions/2774343/how-do-i-associate-file-types-with-an-iphone-application) – Jenn Aug 10 '13 at 16:17

2 Answers2

0

This entry looks rather incomplete to me. Generally if yor application is able to open certain types you need to have either an import declaration (if the file format is owned by another application) or an export declaration (if the format is owned by your)

iOS and Mac are matching UTIs mostly by extension, so I guess you also need to have that in the declaration. Check with the UTI functions on iOS is there is indeed the public.vCard type assigned to your file's extension. If not, then it cannot be found.

I would add an UTImportedTypeDeclarations to your plist if there is such an association, if not add an UTExportedTypeDeclarations

I wrote this tutorial to explain all the things you need: http://www.cocoanetics.com/2012/09/fun-with-uti/

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
0

This seems to be impossible as of iOS 7.0.4.

iOS seems to handle some file types within the Mail app differently than others. Within the Mail app you won't get the option to open those file types in apps that are not from Apple.

You can verify this by using the UIDocumentInteractionController to open a file programmatically. This will prompt the user to open the file in a lot of apps (in all apps that registered this file type or a more general one. The Dropbox app e.g. almost opens everything).

When you mail yourself the exact same file and try to open it within the Mail app you'll not get those options (like Dropbox).

I verified this by registering VCard/.vcf, Jpegs and a custom type.

Klaas
  • 22,394
  • 11
  • 96
  • 107