This page explains how you can get started quickly with the Videola.io SDK for iOS.
The Videola.io SDK for iOS supports iOS 9 and higher.
Since the SDK accesses the device’s camera and microphone, you will need to add the NSCameraUsageDescription
and NSMicrophoneUsageDescription
keys to your application’s Info.plist, with string values explaining to the user how the app uses this data.
You will need to set “Enable Bitcode” to NO in your build settings. Go to Target -> Build Settings -> Enable Bitcode to do so.
Finally, to allow the calls to continue in the background, check the “Audio, AirPlay, and Picture in Picture” checkbox under Capabilities -> Background Modes.
If you don’t have CocoaPods installed, install it with the following command:
1 |
gem install cocoapods |
Then, add the VideolaSDK
pod to your Podfile
:
1 2 3 4 5 6 |
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' target 'TargetName' do pod 'VideolaSDK' end |
Finally, run the following command in your project directory:
1 |
pod install |
First, import the Videola.io SDK in your AppDelegate
and ViewController
as follows:
1 |
@import VideolaSDK; |
Then, register your client ID after application startup in your AppDelegate
:
1 2 3 |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [VideolaCallManager setClientId:@"demo"]; } |
Once the above are in place, the ViewController
sample below will launch a call screen to connect to the videolaiorocks
call room.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
- (void)viewDidLoad { [super viewDidLoad]; [VideolaCallManager setDelegate:self]; [VideolaCallManager callCode:@"videolaiorocks" videoCall:YES onViewController:self callCreationCompletion:^(CallInitError creationError) { if (creationError != CallInitErrorNone) { // Show error here } }]; } - (void)requestToSignApiAuthToken:(NSString *)token { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://demo.videola.io/signer"]]; [request setHTTPMethod:@"POST"]; [request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:[token dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:nil delegateQueue:nil]; [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if ([data isKindOfClass:[NSData class]]) { NSString *signedToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; [VideolaCallManager authorize:signedToken]; } else { [VideolaCallManager authorize:nil]; } }] resume]; } - (void)callEstablished {} - (void)callEnd:(VideolaCallEndReason)reason {} - (void)recordingStateChanged {} |
Let’s break down this example.
VideolaCallManager
.videolaiorocks
call room. We pass YES
in the videoCall
parameter to start the call with the camera on, as well as supply a callback block to be called in case of an initialization error. Check out SDK Reference for more details on the initialization.requestToSignApiAuthToken
event used for SDK authentication. It uses a server endpoint provided by Videola.io to sign tokens for the demo
client ID as part of the authentication scheme. Note that when using a production client ID, you will need your own endpoint as well as a way to authenticate your app with it.