Documentation

VKit Guide

Let's Begin Integrating

Installing VKit

First get the latest version of VKit.

Install VKit into your project by selecting the project file and going into the General tab.

General Tab

There you should tap on the + button under the Embedded Binaries section.

Embedded Section

When the Choose items to add: dialog box is shown, click on the Add Other button.

Choose Item Dialog

A file chooser dialog should come up and from there you should locate and select VKit.framework file.

In the Choose options for adding these files dialog, ensure that Copy items if needed and Create groups are selected. Click on Finish

Option Dialog

You're all set and VKit has been installed into your project.

Integrate VKit

There are two ways to be authorized in V: secure and insecure.

Secure way: you need to generate user authorization token using sessions API, your secret application token and unique user identity.

Insecure way: DANGER, only for testing purposes. After you got your app ID and app secret token, you can authorize your app in video.io by app secret token.

Go to your AppDelegate.swift or AppDelegate.m and be sure to import the framework.

import VKit

Add these codes in the following functions.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    // These 5 lines of code are needed
    VKAccount.current.secureModeEnabled = true
    VKAccount.current.authToken = "current user auth token"
    VKAccount.current.appID = "your app id"
    VKAccount.current.startSession { (accountState, error) in
        // ... Your code ...
    }

    //  Or use following code for insecure authorization, use it only during development
    VKAccount.current.secureModeEnabled = false
    VKAccount.current.appSecretToken = "your app secret token"
    VKAccount.current.appID = "your app id"
    VKAccount.current.startSession { (accountState, error) in
        // ... Your code ...
    }

}

Instead of reacting in startSession callback, you can subscribe to VKNotificationConstants.AccountStateChanged notification and observe it's state.

NotificationCenter.default.addObserver(forName: Notification.Name(rawValue: VKNotificationConstants.AccountStateChanged), object: nil, queue: OperationQueue.main) { (_) in
    // ... Your code ...
}

func applicationWillTerminate(application: UIApplication) {

    VKAccount.current.stopSession()

}

Verify VKit Works

Run your project and in your console output you should see the following:

[VKit] Session started!

Ready to Develop?

Now that you've successfully installed and integrated VKit into your project lets start the fun!

Click on the area that you're interested in.

Areas Description
Query Videos Focus on getting a playlist of videos from the store service.
Playing Videos Here you will learn about the video player and how to play a video.
Advanced video playback You will find out how to build feed of mixed content using VKPlayersManager.
Recording Videos Learn to use the recorder view to record videos that will get into the store.
Live Streaming Here you will learn how to organize live streaming and play saved stream afterward.