从Mail App共享扩展无法在IOS中使用

时间:2020-02-17 07:12:15

标签: ios share-extension

我正在开发具有共享扩展名的应用程序。来自Mail App的具有共享扩展名的共享附件不起作用。但是从gmail应用程序共享附件(pdf,doc,图像等)可以正常工作。

我的Swift代码:

    for attachment in contents{
        if attachment.hasItemConformingToTypeIdentifier(kUTTypeImage as String) {
            attachment.loadItem(forTypeIdentifier: kUTTypeImage as String, options: nil) { data, error in
                //Do action for image
            }
        } else  {
            if let item = (filePicker!.types as [String]).first(where: { (item) -> Bool in attachment.hasItemConformingToTypeIdentifier(item)}){

                attachment.loadItem(forTypeIdentifier: item, options: nil) { data, error in
                    //Do action for file
                }
            }
        }
    }

MY NSExtensionActivationRule:

      <key>NSExtensionActivationRule</key>
        <dict>
            <key>NSExtensionActivationSupportsFileWithMaxCount</key>
            <integer>1</integer>
            <key>NSExtensionActivationSupportsImageWithMaxCount</key>
            <integer>1</integer>
            <key>NSExtensionActivationSupportsAttachmentsWithMaxCount</key>
            <integer>1</integer>
        </dict>

0 个答案:

没有答案