Skip to main content
Version: iOS SDK v1.0.11

Realtime Notifications

VideoKitCore uses WebSockets to inform you about new videos that are being uploaded (from other users) or being processed by our backend.

The realtime connection is established automatically after starting your Session.

Observing Realtime Events

In Version 1.0.3, realtime notifications are internally observable using NotificationCenter.

VKVideoCreated

NotificationCenter is posting a .VKVideoCreated event with the following data structure:

["video": video as! VKVideo]

Whereas video is the newly created video object (VKVideo).

Listen to the event:

NotificationCenter.default.addObserver(self, selector: #selector(handleVideosCreated(_:)), name: .VKVideoCreated, object: nil)

Handle the notification:

@objc func handleVideosCreated(_ notification: Notification) {
if let userInfo = notification.userInfo as? [String : Any], let video = userInfo["video"] as? VKVideo {
// Do something with the video (e.g. add to your playlist, insert into your feed)
}
}

After the video has been uploaded, at 0:18 you can see the realtime notification coming in and the video is getting added to the local device (that recorded it) as well as the two Simulator devices.

VKVideoUpdated

In case a video gets updated, this usually means we finished processing and encoding it, you will receive a .VKVideoUpdated notification you can listen to. The event has the following data structure:

["videoID": videoID, "changes": changes]

Where videoID is the id of updated video and changes is dictionary with the changes of the video.

NotificationCenter.default.addObserver(self, selector: #selector(handleVideosUpdated(_:)), name: .VKVideoUpdated, object: nil)

Get VideoID and changes from Notification

@objc func handleVideosUpdated(_ notification: Notification) {
if let userInfo = notification.userInfo as? [String : Any],
let videoID = userInfo["videoID"] as? String,
let changes = userInfo["changes"] as? [String : Any] {
// Do something with the video (e.g. update your playlist)
}
}

VKVideoDeleted

In case a video gets deleted from our backend you will receive a .VKVideoDeleted notification.

NotificationCenter.default.addObserver(self, selector: #selector(handleVideosDeleted(_:)), name: .VKVideoDeleted, object: nil)

Get VideoID from Notification

@objc func handleVideosDeleted(_ notification: Notification) {
if let userInfo = notification.userInfo as? [String : Any], let videoID = userInfo["videoID"] as? String {
// Do something with the video (e.g. delete video from your playlist, remove video from feed)
}
}