Skip to main content

8. Download Events/Callbacks

Notice

This document is a machine-translated draft and is currently undergoing review. Some content may be inaccurate or differ from the original Korean version. For the most precise information, refer to the Korean documentation.

This section explains how to integrate callback interfaces that notify the application layer of traffic status changes and DRM validation events occurring during download pipeline execution. The iOS SDK uses a single KollusStorageDelegate protocol to handle download progress, DRM authentication responses, and LMS statistics transmission results in a unified manner.


Kollusstoragedelegate protocol

A single unified delegate interface specification that must be implemented to collect storage and security events.

@objc protocol KollusStorageDelegate: NSObjectProtocol {

// Status changes during download (progress/completion/error notification)
func kollusStorage(_ storage: KollusStorage,
downloadContent content: KollusContent,
error: Error?)

// DRM callback response
func kollusStorage(_ storage: KollusStorage,
request: [AnyHashable: Any],
json: [AnyHashable: Any]?,
error: Error?)

// DRM batch renewal progress notification
func kollusStorage(_ storage: KollusStorage,
cur: Int32, count: Int32,
error: Error?)

// LMS (learning statistics) callback response
func kollusStorage(_ storage: KollusStorage,
lmsData: String,
resultJson: [AnyHashable: Any])

// Batch transmission completion for unsent LMS data
func onSendCompleteStoredLms(_ successCount: Int32,
failCount: Int32)
}

Download progress, completion, and error branching

The iOS SDK combines progress updates, final download completion, and task failure events into a single downloadContent:error: method call. Implement this using the conditional branching pattern shown below.

func kollusStorage(_ storage: KollusStorage,
downloadContent content: KollusContent,
error: Error?) {
if let error = error {
// Error
let code = (error as NSError).code
return
}
if content.downloaded {
// Download complete
} else {
// Download in progress (calculate progress using content.downloadProgress and content.downloadSize)
}
}

Event-callback mapping

Standard eventCallback location
Download startedImmediately after a successful try storage.downloadContent(mck) method call
Progress changeddownloadContent:error: (error == nil, downloaded == false)
Download pausedNo dedicated callback (same as cancel)
Download resumedNo dedicated callback (same as start)
Download completeddownloadContent:error: (error == nil, downloaded == true)
Download faileddownloadContent:error: (error != nil)
License expiredcontent.DRMExpired = true (exposed on the next playback attempt)
License renewal resultkollusStorage(_:cur:count:error:)

LMS callback

For content with playback progress rate and Learning Management System(LMS) integration enabled, the SDK automatically collects player playback logs and transmits them to the statistics server. When transmission is processed, the result is notified to the app layer via the delegate's lmsData:resultJson: method.

If statistics data transmission fails due to a network error, the SDK safely stores the missing data in the device's local storage and retransmits it in bulk at the next available network opportunity.

// (Optional) Trigger batch transmission of locally stored LMS data at the desired time
storage.sendStoredLms()

// Batch retransmission completion notification
func onSendCompleteStoredLms(_ successCount: Int32, failCount: Int32) {
// Success or failure count
}