Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I record a video in my app and write it it to the temp directory to allow the user to share it through UIActivityViewController. The video can successfully be played back in-app, and through UIActivityViewController can successfully be sent through Messages, shared to Facebook, and saved to camera roll. But when I try to share through WhatsApp, I get the following error:

Failed to determine whether URL /private/var/mobile/Containers/Data/Application/E7F57458-A5F9-44CB-86FA-ACC4309C7473/tmp/65CB72B3-373E-42F2-8A80-9888E00C2268.mp4 (n) is managed by a file provider

I have been unable to find much information on this error. Does anyone know why this may be occurring?

like image 887
Jake G Avatar asked May 25 '18 22:05

Jake G


2 Answers

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)

like image 87
Jake G Avatar answered Nov 15 '22 22:11

Jake G


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];
}
like image 1
WINSergey Avatar answered Nov 15 '22 23:11

WINSergey