UIActivityViewController Error: Failed to determine whether URL is managed by a file provider

别等时光非礼了梦想. 提交于 2019-12-01 17:26:52

Found a fix:

I was opening a UIActivityViewController with the video url and a string as the activityItems. Passing just the video url fixed the issue of WhatsApp not recognizing the video. It's annoying to not be able to pass in the text, but at least the video is now there.

Does not work:

UIActivityViewController(activityItems: [url, "Check out my video!"], applicationActivities: nil)

Does Work:

UIActivityViewController(activityItems: [url], applicationActivities: nil)

I have the same error. What happens, actually - every app run the path to the file is not the same but I don't remember why I save not just the name of the file - but the whole path. Reasonable when I try to read it - I'll get nothing. Example - if I save the file each app run:

/var/mobile/Containers/Data/Application/1265C296-F2B1-44D6-AD3D-6F2DD59557D3/Documents/what.jpeg
/var/mobile/Containers/Data/Application/B2B53592-B327-48E9-BF70-BE2826022271/Documents/what.jpeg
/var/mobile/Containers/Data/Application/2505B73F-27EF-4B5C-8D21-EB49A45ABE99/Documents/what.jpeg

Right practice - use Document folder path from FileManager, you can found more info here

+ (NSURL *)getDocumentsDirectoryPath {
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]lastObject];
}

I had the same problem when I ran my app on the Simulator. However it was working as expected when I ran the app on a real device.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!