Getting Started =============== Please note the following: **The JumpChat SDK DOES NOT work with the simulator.** Follow the steps and you should be able to add video chat into your iOS app. Here's an overview of the things you'll accomplish in this tutorial. .. contents:: Overview :depth: 2 :backlinks: top Step 1: Download JumpChat iOS SDK --------------------------------- Download the sdk from the following `url `_ and unzip the file. .. code-block:: sh % wget https://dl.jumpch.at/sdk/jumpchat-ios-sdk-latest.zip Step 2: Update project to use the SDK ------------------------------------- Copy the JumpChatSDK.framework into your project. Select project settings and *General* tab. Make sure JumpChatSDK.framework is added. Also add ``VideoToolbox.framework``, ``libicucore.tbd``, and ``libstdc++.tbd``. .. code-block:: bash JumpChatSDK.framework VideoToolbox.framework libicucore.tbd libstdc++.tbd .. image:: img/add_framework.png Disable Bitcode. .. image:: img/disable_bitcode.png Allow ``jumpch.at`` domain to ``App Transport Security Settings``. You can add the following to your ``Info.plist`` .. code-block:: xml NSAppTransportSecurity NSExceptionDomains jumpch.at NSExceptionAllowsInsecureHTTPLoads Your ``Info.plist`` should look like this in the settings afterwards. .. image:: img/add_apptransport.png Add the following linker flags. .. code-block:: bash -ObjC .. image:: img/link_flags.jpg Step 3. Implement client delegate --------------------------------- Implement the client delegate methods. Add ``JCClientDelegate`` to the interface definition of the ``UIController`` class. Implement the ``videoAdded`` and ``videoRemoved`` methods specified from the ``JCClientDelegate`` protocol. .. code-block:: objc #import ... // Step 3. Add JCClientDelegate protocol to interface definition @interface ViewController () ... @end // Step 3. Implement client delegate #pragma mark JumpChat Client Delegate - (void)jc:(JCClient *)jc videoAdded:(NSString *)userid view:(JCGLVideoView *)view { [self.view addSubview:view]; } - (void)jc:(JCClient *)jc videoRemoved:(NSString *)userid view:(JCGLVideoView *)view { [view removeFromSuperview]; } Step 4. Create the JumpChat client object ----------------------------------------- In your UIController class, create a ``jc`` property to save the ``JCClient`` object. Then create a ``JCClient`` object with ``initWithDelegate:`` method. .. code-block:: objc #import ... @interface ViewController () ... // Step 4. Create property to save JCClient @property (nonatomic, strong) JCClient *jc; ... @end - (void)viewDidLoad { [super viewDidLoad]; ... // Step 4. Create the JumpChat client object self.jc = [[JCClient alloc] initWithDelegate:self options:nil]; ... } Step 5. Start broadcasting -------------------------- In your UIController class, create a JCClient object with ``initWithDelegate:`` method. This will start broadcasting and create a local video object. .. code-block:: objc - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // Step 4. Create the JumpChat client object self.jc = [[JCClient alloc] initWithDelegate:self options:nil]; // Step 5. Start broadcasting [self.jc startBroadcasting]; } Step 6. Join room ----------------- Create a button button and hook up a method to connect & disconnect. .. code-block:: objc #import ... @interface ViewController () ... // Step 4. Create property to save JCClient @property (nonatomic, strong) JCClient *jc; // Step 6. Connect button @property (weak, nonatomic) IBOutlet UIButton *connectButton; ... @end - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // Step 4. Create the JumpChat client object self.jc = [[JCClient alloc] initWithDelegate:self options:nil]; // Step 5. Start broadcasting [self.jc startBroadcasting]; // Step 6. Setup toggle text. [self.connectButton setTitle:@"Connect" forState:UIControlStateNormal]; [self.connectButton setTitle:@"Disconnect" forState:UIControlStateSelected]; } ... // Step 6. Implement connect button - (IBAction)onConnectButton:(id)sender { UIButton *btn = (UIButton *)sender; if (btn.selected == NO) { [self.jc join:@"aaaaaaaaaa" type:@"random"]; btn.selected = YES; } else { [self.jc leave]; btn.selected = NO; } }