6
votes

I'm working on an iOS (iPhone/iPad) app that does a web service call where one of the parameters is a .pfx file.

I would like for the user to be able to import his own .pfx file into the app by selecting its attachment in an email (the app already does this for a custom file type, whose entries are not shown below, but are very similar).

In the app's Info.plist file, I've added an entry in the CFBundleDocumentTypes tag and one in the UTExportedTypeDeclarations tag, as shown below. In the UTExportedTypeDeclarations I used for the identifier 'com.rsa.pkcs-12', which is one of the UTI's for pfx files. I looked up and entered the standard MIME type of a pfx file (application/x-pkcs12).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
...
<key>CFBundleDocumentTypes</key>
<array>
            ...
    <dict>
        <key>CFBundleTypeName</key>
        <string>Personal Information Exchange</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.rsa.pkcs-12</string>
        </array>
    </dict>
</array>
...
    <key>UTExportedTypeDeclarations</key>
<array>
            ...
    <dict>
        <key>UTTypeConformsTo</key>
        <array/>
        <key>UTTypeDescription</key>
        <string>Personal Information Exchange</string>
        <key>UTTypeIdentifier</key>
        <string>com.rsa.pkcs-12</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>pfx</string>
            <key>public.mime-type</key>
            <string>application/x-pkcs12</string>
        </dict>
    </dict>
</array>
</dict>
</plist>

This doesn't work. When I open a pfx file attachment in Mail, it opens in Settings (it wants to install the file as a profile). Of course, the pfx file type already exists in iOS, so it should not really be necessary to make an entry in UTExportedTypeDeclarations; however, removing this entry makes no difference. The same behaviour occurs when I use a custom identifier in both entries (instead of "com.rsa.pkcs-12").

I would not like to force the user to change the extension of the file of the attachment. Is there a way I can tell iOS to ask the user whether to open the file with Settings or my app?

2

2 Answers

3
votes

It looks like this is not possible for a special file such as a .pfx .

I've changed my app so that it accepts files with a special extension. The app instructs the user to change the extension of the .pfx file to the special extension before emailing it to him/herself to import it into the app.

0
votes

You can use Share Extension with out renaming the file extension