Naho
Naho

Reputation: 21

Sharing asset library video on ios with swift

I save a video file to Library and then try to share the NSURL of the asset library with UIActivityViewController.

For some apps like viber it works, but some other like whatsapp and Gmail the URL is shared instead of video file itself.

here is an example assets-library://asset/asset.mov?id=944F2398-FE49-44EA-9AF1-41EBC017EA64&ext=mov

any idea how to share the video file from library with Swift and UIActivityViewController ?

let activityViewController : UIActivityViewController = UIActivityViewController(activityItems: [videoURL], applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)

Upvotes: 2

Views: 1189

Answers (1)

Armin
Armin

Reputation: 659

You need to provide the actual physical file path. Example URL:

file:///var/mobile/Containers/Data/Application/path-to-my-videos-folder/my-video.mp4

One issue that I see happening with your journey is that the share dialog will have the option to save to library again, so feels like you're spinning in circle there.

I hope this helps.

Upvotes: 0

Related Questions