iOS SDK Integration Architecture
The iOS SDK is a fast and effective way to include a live video chat in a mobile application. The SDK makes it easy to embed one to one, many to many high-quality voice and video calls into your mobile app, with a seamless integration with the Android/iOS operating system. It features a fully fledged set of collaborative tools comprehensive of: messaging, screen sharing, remote snapshot, collaborative interactive board and call recording capabilities.
The following diagram represents the most common integration layout of the Mobile SDK and the section following the diagram elaborates on the flow:
Note:
The access token used by the SDK is obtained on the server side. This implementation ensures that the apiKey is not shared publicly, and the access token is bound to the user session on the integrated website.
Using the apiKey on the client side is strongly discouraged and should be absolutely avoided in production.
1. Authenticate User
The user accesses the application by leveraging an authentication method of choice. User authentication is done externally from Kaleyra Video.
2. Obtain Access Token
Refer to the SDK Authentication section.
3. Add SDK
platform :ios, '10.0'
use_frameworks!
target '<YOUR_TARGET_NAME>' do
pod 'Bandyer', ~> 'latestVersion'
end
You can find the latest released version here: https://github.com/Bandyer/Bandyer-iOS-SDK/releases.
4. Make a Video call
You can make a basic integration of the SDK for testing purposes by simply copy-pasting the following snippet of code.
Set userId, appId, region and environment variables as indicated in the following code:
let userId = "user id"
let appId = "app id associated to your account starts with mAppID"
let region = .europe // region to which your account belongs: europe or india;
let environment = .sandbox // .sandbox or .production;
// configure
let config = try! ConfigBuilder(appID: appId, environment: environment, region: region).build()
BandyerSDK.instance.configure(config)
// connect
class TokenProvider: AccessTokenProvider {
func provideAccessToken(userId: String, completion: @escaping (Result<String, Error>) -> Void) {
// rest call to your server to request an accessToken for the user1
completion(.success("accessToken")
}
}
BandyerSDK.instance.connect(Session(userId: userId, tokenProvider: TokenProvider()))
// call
let usersToCall = ["user to call"]
let intent = StartOutgoingCallIntent(callees: usersToCall,
options: .init(callType: .audioUpgradable))
let callWindow = CallWindow.instance ?? CallWindow()
callWindow.presentCallViewController(for: intent)
NSString *userId = @"user id";
NSString *appId = @"app id associated to your account starts with mAppID";
BandyerSDKRegion region = BandyerSDKRegionEurope; // region to which your account belongs: Europe or India;
BandyerSDKEnvironment environment = BandyerSDKEnvironmentSandbox; // BandyerSDKEnvironmentSandbox or BandyerSDKEnvironmentProduction;
// configure
BDKConfig *config = BDKConfigBuilder.create(appId, environment, region).build();
[BandyerSDK.instance configure:config];
// connect
@interface TokenProvider : NSObject <BDKAccessTokenProvider>
@end
@implementation TokenProvider
- (void)provideAccessTokenWithUserId:(NSString * _Nonnull)userId
success:(void (^_Nonnull)(NSString * _Nonnull))success
error:(void (^_Nonnull)(NSError * _Nonnull))failure
{
// rest call to your server to request an accessToken for the user
success(@"accessToken");
}
@end
BDKSession *session = [[BDKSession alloc] initWithUserId:userId tokenProvider:[TokenProvider new] observer:nil];
[BandyerSDK.instance connect:session];
// call
BDKStartOutgoingCallIntent *intent = [BDKStartOutgoingCallIntent intentWithCallees:@[@"user to call"]
options:[BDKCallOptions optionsWithCallType:BDKCallTypeAudioVideo]];
BDKCallWindow *callWindow = BDKCallWindow.instance ?: [[BDKCallWindow alloc] init];
[callWindow presentCallViewControllerFor:intent completion:nil];
Note
In sandbox environment ‘region’ is always ‘eu’.
Good Job!
There are more customizations available. Refer to Video-iOS-SDK for further information.