1

I am new to iOS development. I designed a custom attachment to send through mail. When I receive the attachment in mail, I want to open the attachment in my app. Here is my info.plist

<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
        </array>
        <key>UTTypeDescription</key>
        <string>pvt file</string>
        <key>UTTypeIdentifier</key>
        <string>com.pryvateBeta.crypt.pvt</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>pvt</string>
        </dict>
    </dict>
</array>
<key>CFBundleDocumentsType</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array/>
        <key>CFBundleTypeName</key>
        <string>pvt file</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.pryvateBeta.crypt.pvt</string>
        </array>
    </dict>
</array>

And here is my Appdelegate

func application(application: UIApplication, openURL Url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
    let encrypteddata = NSData(contentsOfURL: Url)
    

    return true
}

I have asked the question before in this LINK. It was a possible duplicate of this QUESTION. But, I didn't get the solution and could not find where the problem is.

What is missing in my code? Any help is appreciated

2
  • Use the Info tab of the app target editor to set up your document types and exported UTIs. It will set up the Info.plist properly.
    – matt
    Aug 19, 2015 at 4:07
  • Is there anything missing in the plist? So that i could add it in the way you mentioned @matt Aug 19, 2015 at 4:19

1 Answer 1

5

try this. i copy and pasted ur code in my plist and its not working. then i created another plist and its code is as below. and its working

       <key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.pryvateBeta.crypt.pvt</string>
        </array>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleTypeName</key>
        <string>pvt file</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
    </dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
        </array>
        <key>UTTypeIdentifier</key>
        <string>com.pryvateBeta.crypt.pvt</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.mime-type</key>
            <string>application/pry</string>
            <key>public.filename-extension</key>
            <string>pvt</string>
        </dict>
    </dict>
</array>
15
  • Unfortunately, no changes yet @Shebin Aug 19, 2015 at 4:19
  • What does the <LSItemContentTypes> really contains? Should it be the Bundle ID + file extension? Aug 19, 2015 at 7:14
  • It really works.. I would like to know one more thing. How can I handle this file? Aug 19, 2015 at 7:22
  • I want to open this in one of my veiwcontrollers. Aug 19, 2015 at 7:25
  • As you mentioned in ur question. that delegate will invoke.. the parameter url contain ur file (path) Aug 19, 2015 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.