Text Chat Accelerator Pack iOS
This project is deprecated
Accelerator Core iOS
The OpenTok Text Chat Accelerator Pack for iOS project is now a part ofThe Text Chat Accelerator Pack provides functionality you can add to your OpenTok applications that enables users to exchange text messages between mobile or browser-based devices.
Text Chat Accelerator Pack Examples
Configure, build and run the sample app
-
Get values for API Key, Session ID, and Token. See Obtaining OpenTok Credentials for important information.
-
Install CocoaPods as described in CocoaPods Getting Started. If you are only interested in the core part without UI component, you can use this
pod 'OTTextChatAccelerator/Core'
-
In Terminal,
cd
to your project directory and typepod install
. -
Reopen your project in Xcode using the new
*.xcworkspace
file. -
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. sharedSession = [[OTAcceleratorSession alloc] initWithOpenTokApiKey:@"apikey" sessionId:@"sessionid" token:@"token"]; return YES; }
-
Use Xcode to build and run the app on an iOS simulator or device.
-
For testing text chat, we include a simple web app to make it easier: Browser-Demo-TextChat. Simply open it and replace the corresponding API Key, Session ID, and Token values. Then save and load it to the browser.
-
You might want to run on other platforms:
Accelerator Textchat Javascript
Accelerator Textchat Android
Sample Codes
-
Passing the session
- (OTAcceleratorSession *)sessionOfOTOneToOneCommunicator:(OTOneToOneCommunicator *)oneToOneCommunicator { return <#OTAcceleratorSession#>; }
-
Start signaling text chat data
// we assume self owns a table tableView [self.textChat connectWithHandler:^(OTTextChatConnectionEventSignal signal, OTConnection *connection, NSError *error) { if (signal == OTTextChatConnectionEventSignalDidConnect) { NSLog(@"Text Chat starts"); } else if (signal == OTTextChatConnectionEventSignalDidDisconnect) { NSLog(@"Text Chat stops"); } } messageHandler:^(OTTextChatMessageEventSignal signal, OTTextMessage *message, NSError *error) { if (signal == OTTextChatMessageEventSignalDidSendMessage || signal == OTTextChatMessageEventSignalDidReceiveMessage) { if (!error) { [weakSelf.textMessages addObject:message]; [weakSelf.tableView reloadData]; } } }];
-
Stop signaling text chat data
[self.textchat disconnect];
Obtaining OpenTok Credentials
To use OpenTok's framework you need a Session ID, Token, and API Key you can get these values at the OpenTok Developer Dashboard . For production deployment, you must generate the Session ID and Token values using one of the OpenTok Server SDKs.
JSON Requirements for Text Chat Signaling
The JSON used when using the OpenTok signaling API with the OpenTok Text Chat component describes the information used when submitting a chat message. This information includes the date, chat message text, sender alias, and sender ID. The JSON is formatted as shown in this example:
// var type = "text-chat"
{
"sentOn" : 1462396461923.305,
"text" : "Hi",
"sender" : {
"alias" : "Tokboxer",
"id" : "16FEB40D-C09B-4491-A983-44677B7EBB3E"
}
}
This formatted JSON is converted to a string, which is submitted to the OpenTok signaling API. For more information, see:
Development and Contributing
Interested in contributing? We
Getting Help
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue on this repository
- See https://support.tokbox.com/ for support options
- Tweet at us! We're @VonageDev on Twitter
- Or join the Vonage Developer Community Slack
Further Reading
- Check out the Developer Documentation at https://tokbox.com/developer/