使用 UIDocumentInteractionController 共享图像时仅显示 whatsapp

Ann*_*Dev 5 ios uidocumentinteraction whatsapp

根据文档https://www.whatsapp.com/faq/en/iphone/23559013,将文件格式设置为 .wai 并将 UTI 设置为 net.whatsapp.image 只会在应用程序列表中显示 Whatsapp,

但它显示了其他应用程序,如添加到笔记,信使也与 whatsapp 选项一起。

    if let imageData = UIImageJPEGRepresentation(image, 1.0)
    { 
        let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
        let documentsDir: AnyObject = path[0]
        let imagePath = documentsDir.stringByAppendingPathComponent("Main")

        NSFileManager.defaultManager().createDirectoryAtPath(imagePath, withIntermediateDirectories: true, attributes: nil)

        let tempFile = NSURL(fileURLWithPath: imagePath+"/image.wai")
        do
        {
            try imageData.writeToURL(tempFile, options: .DataWritingAtomic)
            self.documentController = UIDocumentInteractionController(URL: tempFile)
            self.documentController.UTI = "net.whatsapp.image"
            self.documentController.presentOpenInMenuFromRect(self.view.frame, inView: self.view, animated: true)
        }
        catch
        {
            // alert

        }
    }
Run Code Online (Sandbox Code Playgroud)

请建议我是否在这里做错了什么