簡體   English   中英

我應該如何通過電子郵件發送自己格式的文件,如何才能在iOS 5中自己的應用程序中打開文件?

[英]How should i send file of my own format with email and what should i do to be able to open it in my own application in iOS 5?

我使用MIME類型“ application / tfk”發送文件,並將其寫在Info.plist中:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>My document</string>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>tfk</string>
        </array>
        <key>CFBundleTypeMIMETypes</key>
        <array>
            <string>application/tfk</string>
        </array>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.dmm.tfk</string>
        </array>
    </dict>
</array>

但它不起作用。 我的應用程序不在郵件應用程序的列表中。 我究竟做錯了什么?

我相信您也需要聲明一個UTI。 這是有關統一類型標識符的文檔。

這是您應該添加的示例:

<key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string></string>
            </array>
            <key>UTTypeDescription</key>
            <string>My document</string>
            <key>UTTypeIdentifier</key>
            <string>com.dmm.tfk</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>tfk</string>
                    <string>TFK</string>
                </array>
                <key>public.mime-type</key>
                <string>application/tfk</string>
            </dict>
        </dict>
    </array>

不知道這是否是您所需的全部,但是一旦它起作用,它將把launchOptions發送到您的AppDelegate。 該文件的URL將被發送的UIApplicationLaunchOptionsURLKey關鍵launchOptionsapplication:didFinishLaunchingWithOptions:在你AppDelegate 然后,您可以使用以下代碼從該URL中提取文件數據: NSData dataWithContentsOfURL: 希望有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM