Skip to main content

9. Download Error Codes

The iOS SDK notifies the application layer of exceptions by combining the code property and localizedDescription message of an NSError instance.


SDK error codes

The following are the main error codes classified by (error as NSError).code and their trigger points.

Error typeDescriptionTrigger
Authentication errorSDK key expired or invalid keyAt start() or startWithCheck()
Unsupported deviceDevice does not support SDK or DRMAt start() or when DRM compatibility validation fails
Insufficient storageInsufficient disk spaceAt the start of metadata loading (load) and file download (download)
File write failureFile write errorWhen a disk I/O error occurs during download
Duplicate downloadDuplicate download requestWhen downloadContent(mck) is called for the same content
Download already completeContent already downloadedWhen downloadContent(mck) is called for already downloaded content
Content not foundTarget file not foundAt content removal (removeContent) or validation (checkContentURL)
Expiration date exceededDRM expiration date exceededWhen attempting offline playback
Playback time exceededDRM remaining playback time exceeded (remaining time is 0)When attempting offline playback
Playback count exceededDRM remaining playback count exceeded (remaining count is 0)When attempting offline playback
DRM forced deletionContent forcibly deleted by DRM callback kind2 or kind3 responseWhen a response is detected in the delegate callback (request:json:error:) parameters
Development guidelines

The detailed types of integer code values (code) emitted by the SDK match the ErrorCodes structure of the Android SDK. However, in the iOS development environment, it is recommended to handle exceptions by branching on NSError.code, and to map specific text to the screen using the localizedDescription property.

Error handling example

do {
try storage.start()
} catch {
let nsError = error as NSError
UIApplication.presentErrorViewController(
title: "Error Code: \(nsError.code)",
errorDescription: nil,
errorReason: error.localizedDescription
)
}

External errors

These are response patterns for errors that may occur due to mobile operating system policies or network errors, outside of the SDK's internal logic.

  • Insufficient disk space: It is recommended to call DiskStatus.freeDiskSpaceInBytes before starting a download to check available capacity.
  • Network connection failure: The SDK automatically retries. The automatic retry threshold can be adjusted with storage.setNetworkTimeOut(timeOut:retry:), and the setting storage.setNetworkTimeOut(timeOut: 30, retry: 3) is recommended.
  • Background force termination: To prevent transfers from being cancelled by the operating system when the app moves to the background, it is recommended to enable the setBackgroundDownload(true) setting and review the UIBackgroundModes spec in Info.plist.

Error typeExample user message
Authentication error"There is a problem with app authentication. Please update the app to the latest version."
Insufficient storage"Your device does not have enough storage space. Please delete downloaded files you have finished watching or free up storage space."
File write failure"Failed to save the file. Please try again later."
Expiration error"The content viewing period has expired. Please connect to a network to renew the license."
Unsupported device"Content cannot be downloaded or played on this device."