VMS initialization
Uses Alamofire of 4.8.2 version.
https://github.com/Alamofire/Alamofire
Main entry point to establish connection between application and server.
Initialization
For simple initialization only url of your server is required
import VMSMobileSDK
let apiUrl = "https://example.com"
var api = VMS(
baseUrl: apiUrl,
language: nil,
accessToken: nil
)
api.delegate = self
Language
For now we support only two languages
public enum VMSLanguage: String {
case russian = "ru"
case english = "en"
}
Access token
For authorised users you can set user's access token. In this case you can skip authorization flow. Otherwise SDK will set this parameter by itself after login request.
Delegate
Set delegate if you want to handle errors. Here you will receive all possible errors, but we suggest additionally handle 422 and 429 inside requests. See ApiError
for more details.
public protocol VMSDelegate: AnyObject {
func apiDidReceiveError(_ error: VMSApiError)
}
Download archive
Part of video will be downloaded from url and saved.
func downloadArchiveRequest(
url: URL,
destinationUrl: URL,
progressHandler: @escaping ((Progress) -> Void),
completionHandler: @escaping ((Error?) -> Void)
)
url
- from where download archive
destinationUrl
- where to save downloaded file
progressHandler
- track the progress of downloading process
completionHandler
- will be called when download is finished
Cancel download archive request
cancelDownloadArchiveRequest()