This section shows you how to prepare, build, and run the sample application. The app is built by the Accelerator Core iOS.
Use CocoaPods to install the project files and dependencies.
- Install CocoaPods as described in CocoaPods Getting Started.
- In Terminal,
cd
to your project directory and typepod install
. - Reopen your project in Xcode using the new
*.xcworkspace
file.
Configure the sample app code. Then, build and run the app.
-
Get values for API Key, Session ID, and Token. See OpenTok One-to-One Communication Sample App home page for important information.
-
Replace the following empty strings with the corresponding API Key, Session ID, and Token values:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [OTAcceleratorSession setOpenTokApiKey:@"" sessionId:@"" token:@""]; return YES; }
-
Use Xcode to build and run the app on an iOS simulator or device.
For detail about the APIs used to develop this sample, see the OpenTok iOS SDK Reference.
NOTE: This sample app collects anonymous usage data for internal TokBox purposes only. Please do not modify or remove any logging code from this sample application.
The OTOneToOneCommunicator
class is the backbone of the one-to-one communication features for the app. This class conforms to the protocols that initiate the client connection to the OpenTok session and sets up the listeners for the publisher and subscriber streams:
[self.oneToOneCommunicator connectWithHandler:^(OTOneToOneCommunicationSignal signal, NSError *error) {
if (!error) {
if (signal == OTSessionDidConnect) {
// publisher view is available, now you can add subscriber view to your desired view
}
else if (signal == OTSubscriberDidConnect) {
// subscriber view is available, now you can add subscriber view to your desired view
}
}
else {
}
}];
The following enum notifies the main controller of all session, publisher, and subscriber events:
typedef NS_ENUM(NSUInteger, OTOneToOneCommunicationSignal) {
OTSessionDidConnect = 0,
OTSessionDidDisconnect,
OTSessionDidFail,
OTSessionStreamCreated,
OTSessionStreamDestroyed,
OTSessionDidBeginReconnecting,
OTSessionDidReconnect,
OTPublisherDidFail,
OTPublisherStreamCreated,
OTPublisherStreamDestroyed,
OTSubscriberDidConnect,
OTSubscriberDidFail,
OTSubscriberVideoDisabledByPublisher,
OTSubscriberVideoDisabledBySubscriber,
OTSubscriberVideoDisabledByBadQuality,
OTSubscriberVideoEnabledByPublisher,
OTSubscriberVideoEnabledBySubscriber,
OTSubscriberVideoEnabledByGoodQuality,
OTSubscriberVideoDisableWarning,
OTSubscriberVideoDisableWarningLifted,
};
To develop your one-to-one communication app:
- Install Xcode version 5 or later.
- Review the OpenTok iOS SDK Requirements.