Problem with arguments for PhotoLibrary.saveVideo

I am attempting to save a video to the PhotoLibrary on an iPhone. When I run the app on an actual iPhone and debug with Xcode, I receive the following error:

could not cast value of type ‘__nsdictionarym’ to ‘nsstring’

This occurs when the following line is called in the saveVideo function of the PhotoLibrary.swift class:

let url = command.arguments[0] as! String

And the following is the Typescript used to create the call to the saveVideo function where ‘file’ is of the form ‘’:

			response => {
				this.photoLibrary.saveVideo(file,"Test Videos");

Any help would be much appreciated. Does my ‘file’ variable need to be of a different format?

1 Like

You have to download the video first in the temp folder, then, you could save it to the Library.
This is more a copy paste but it works like a charm.

Thanks for the response, but I’m not sure I understand. What difference would it make if I save it to a temp folder first? Would I not still have the same problem?

I would still be passing a path to an mp4 as the first ‘file’ argument in the saveVideo function, right?

Yeah but a path not an URL while you said :

OK, so that argument must be a path?

I have also never saved a temporary file before. Is this the best API to use for that?

Never tried, you could try! :wink: