SDK Initialization


Contents

1. Initialize with SDK Domain
2. Set the SDK Resource Bundle's Path (Optional)
3. Set Root Navigation Controller (Optional)
4. Authenticate with Access Credentials 
5. Log feature

Main Thread

Please note that SDK initialization and all API call must run in Main Thread.

To integrate with our Zoom SDK and have all Zoom services working, the Zoom SDK instance needs to be initialized. The MobileRTC object exposes a generic interface to allow initialization, authentication, and configuration.

To initialize the object, first you need to implement the didFinishLaunchingWithOptions method in AppDelegate.m.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
}

Next, implement with the following steps to initialize Zoom SDK:

Step 1: Initialize with SDK Domain

MobileRTC = Zoom SDK

You will see the term “MobileRTC” in our iOS library, it is the technical name of our SDK library, you can treat it as the term “Zoom SDK”.

//1. initSDK
[MobileRTC initializeWithDomain:kSDKDomain enableLog:NO];
Please do not use raw IP address as the web domain

Please do not use raw IP address as the web domain as it will cause vulnerability issues. If you would like to learn why, please see our security practices for more information.

Step 2: Set the SDK Resource Bundle’s Path (Optional)

This step is optional. If and only if your MobileRTC Resource Bundle is included in another bundle or framework, please use this method to set its path.

//2. Set MobileRTC Resource Bundle path
//Note: This step is optional, If MobileRTCResources.bundle is included in other bundle/framework, use this method to set the path of MobileRTCResources.bundle, or just ignore this step
SString *bundlePath = [[NSBundle mainBundle] bundlePath];
[[MobileRTC sharedRTC] setMobileRTCResPath:bundlePath];

Step 3: Set Root Navigation Controller (Optional)

This step is also optional. You can skip this step if and only if your app’s Root View Controller is not a UI Navigation Controller.

...
MainViewController *mainVC = [[[MainViewController alloc] init] autorelease];
UINavigationController *navVC = [[[UINavigationController alloc] initWithRootViewController:mainVC] autorelease];
navVC.navigationBarHidden = YES;
...
//3. Set Root Navigation Controller
//Note: This step is optional, If app’s rootViewController is not a UINavigationController, just ignore this step.
[[MobileRTC sharedRTC] setMobileRTCRootController:navVC];

Step 4: Authenticate with Access Credentials

To initialize Zoom SDK, firstly you need to call getAuthService from MobileRTC, and insert parameters. In the end, pass sdkAuth method to authService to perform an authentication process on initializing Zoom SDK:

sdkAuth
- (void)SDKAuth:(NSString *)clientKey clientSecret:(NSString *)clientSecret
{
    self.clientKey = clientKey;
    self.clientSecret = clientSecret;
    MobileRTCAuthService *authService = [[MobileRTC sharedRTC] getAuthService];
    if (authService)
    {
        authService.delegate = self;
        authService.clientKey = clientKey;
        authService.clientSecret = clientSecret;
        // Here need add your jwtToken, if jwtToken is nil or empty,
				// we will use your clientKey and clientSecret. We recommend using JWTToken.
        authService.jwtToken = KjwtToken;
        [authService sdkAuth];
    }
}

Method properties:

Properties Definition
delegate The property that acts as the delegate of the receiving auth/login events.
clientKey The key value is used during the authorization code grant.
clientSecret The secret value is used during the authorization code grant.
jwtToken JSON Web Token

For a guide on setting up your SDK Client Key and Client Secret, reference our guide to Create an SDK App on the Marketplace.

Initialize using Client Key / Secret

To initialize with Client Key and Secret, pass both a clientKey and clientSecret to the sdkAuth method.

If a clientKey and clientSecret is not passed, a jwtToken should be used.

Initialize using JWT

As of iOS SDK version 4.4.57220.1211, the iOS SDK can be initialized using JWT for added security, convenience and versatility.

To initialize with JWT, pass a jwtToken string to the sdkAuth method.

If no JWT is passed, clientKey and clientSecret should be used.

Composing JWT for SDK Initialization

Zoom SDKs support JWTs generated with JWT.io libraries on a backend server. While other libraries can be used to create JWT, these recommended libraries are the most robust.

JWT is generated with three core parts: Header, Payload, and Signature. When combined, these parts are separated by a period to form a token: aaaaa.bbbbb.cccc. Follow this template to compose your payload for SDK initialization.

For further information, reference our guide to JSON Web Tokens (JWT).

Header

The Header includes the specification of the signing algorithm and the type of token.

{
"alg": "HS256",
"typ": "JWT"
}

Payload

The payload of a JWT contains the claims of the token, or the pieces of information being passed about the user and any metadata required.

{
  	"appKey": "string", // Your SDK key
"iat": long, // access token issue timestamp
"exp": long, // access token expire timestamp, iat + a time less than 48 hours
	"tokenExp": long // token expire time, MIN:1800 seconds
}

The minimum value of tokenExp should be at least 30 minutes, otherwise, the authentication request will be rejected.

Signature

To create a signature for the JWT, the header and payload must be encoded with the SDK Secret through an HMAC SHA256 algorithm.

HMACSHA256(
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
YOUR_SDK_SECRET
)

Your signature does not need to be base64 encoded. Once the token is generated, do not reveal or publish it. It is highly recommended to handle your SDK Key and Secret and generate a JWT in a backend server to be consumed by your application. Do not generate JWT in a production environment.

Monitor Auth Status

To monitor the status or catch errors during the initialization process, implement the onMobileRTCAuthReturn method:

- (void)onMobileRTCAuthReturn:(MobileRTCAuthError)returnValue
{
   NSLog(@"onMobileRTCAuthReturn %d", returnValue);
    
    if (returnValue != MobileRTCAuthError_Success)
    {
        NSString *message = [NSString stringWithFormat:NSLocalizedString(@"SDK authentication failed, error code: %zd", @""), returnValue];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:message delegate:self cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:NSLocalizedString(@"Retry", @""), nil];
        [alert show];
    }
}
(returnValue == MobileRTCAuthError_Success) is the pre-requisite of every other services

You will not be able to use any other services(such as login, logout, join meeting, start meeting, etc.) if you do not receive a MobileRTCAuthError_Success value as the returnValue in the onMobileRTCAuthReturn method.

Log Feature

The log feature is introduced with SDK v4.3.30728.0118, you can enable the log feature when initializing Zoom SDK with the following method:

//1. initSDK, must be called at the very beginning of the didFinishLaunchingWithOption method.
[MobileRTC initializeWithDomain:kSDKDomain enableLog:YES];
Set enableLog: YES but not log?

Please beware that you must call [ MobileRTC initializeWithDomain:kSDKDomain enableLog: YES] method at the very beginning of your didFinishLaunchingWithOption, and you must not call any other methods that involve sharedRTC before you call [ MobileRTC initializeWithDomain:kSDKDomain enableLog: YES] method because calling methods that involve sharedRTC will initialize a MobileRTC instance with log feature disabled.

Once the log feature is initialized, a log file will be created inside the sandbox of your application. The following steps shows how to retrieve your log file:

Step 1: Open the sandbox

In Xcode, select Devices and Simulators under Window menu:

Step 2: Download sandbox contents

Locate your application and press the small gear icon, then select “Download Container”:

Select a path to store the container contents, an xcappdata file will be created.

Step 3: Locate log file

Locate the xcappdata file created from the previous step, right click on the file and select “Show Package Contents”:

Inside the package contents, you will find the log file under: /AppData/tmp/

The log file has a 5MB storage capacity(fixed). Once it reaches the maximum capacity, it will auto re-record from the begining and overrider the previous data.