Presenting BoldChatViewController from Code

The following code is needed to create a BoldChatViewController instance.

BCAccount *account= [BCAccount accountWithAccessKey:@"<access key from web setup>"];
BoldChatAccountSettings *accountSettings = [[BoldChatAccountSettings alloc] init];
accountSettings.account = account;
accountSettings.visitorId = <customer id to track the user>;

BoldChatViewSettings *viewSettings = [[BoldChatViewSettings alloc] init];

BoldChatViewController *boldChatViewController = [[BoldChatViewController alloc] initWithAccountSettings:accountSettings viewSettings:viewSettings language:nil];

If viewSettings.formSubmitStyle is BoldChatViewSettingsFormSubmitStyleLastCell and viewSettings.endChatStyle is BoldChatViewSettingsEndChatStyleOnChatView no navigation controller is needed to contain the view controller. Otherwise create one:

UINavigationController *navControllerWithBoldChat = [[UINavigationController alloc] initWithRootViewController:boldChatViewController];

Several ways of Displaying the View Controller

Display as a Modal

chatViewController = ...//view controller or the navigation controller that has it
[self presentViewController:chatViewController animated:YES completion:nil];

Add to an Existing Navigation Controller

[navigationController pushViewController:self.boldChatViewController animated:YES];

Add to a Tab Bar Controller

chatViewController = ...//view controller or the navigation controller that has it
tabBarController setViewControllers:@[..
                                                   chatViewController,
                                                   ..
                                                   ]];

Adding With Containment API to Any Other View Controller

chatViewController = ...//view controller or the navigation controller that has it
[containerViewController addChildViewController:chatViewController];
containerViewController.chatViewController.view.frame = <Rect>;
[containerViewController.view addSubview:chatViewController.view];
[chatViewController didMoveToParentViewController:containerViewController];  

After presenting the view controller it needs to be started

[boldChatViewController start];