谁能告诉我如何在 iphone sdk 中实现语音聊天。游戏用于通过蓝牙进行语音聊天..我希望我的应用程序可以通过互联网进行语音聊天选项
谢谢亚西尔
Apple 的 GameKit 框架提供了实现游戏内聊天所需的一切。
完整的文档在这里:
假设您已经使用 GameKit 将 App 连接到一个或多个其他玩家,您可以像这样开始语音聊天:
-(void) startInGameChat {
//Set up audio session
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:myErr];
[audioSession setActive: YES error: myErr];
GKMatch* match;
GKVoiceChat *teamChannel = [[match voiceChatWithName:@"redTeam"] retain];
GKVoiceChat *allChannel = [[match voiceChatWithName:@"allPlayers"] retain];
//Start the chat
[teamChannel start];
//Enable Mic
teamChannel.active = YES;
}
使用 XMPP 框架的一种最佳方法。使用 XMPP,您可以将文件和文本发送给其他人。使用它,您可以录制语音消息并将其发送出去。我做了很多研发工作,以使用 XMPP 协议在 ios 上实现 jabber 服务器。
有关更多信息,请移至链接:使用 XMPP 协议实现 jabber。
http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/
您还可以在 ios 中查看此链接进行简单聊天:http: //www.ibm.com/developerworks/library/x-ioschat/