How to implement voice & text chat between two iOS device

守給你的承諾、 提交于 2019-12-03 21:36:45

I think one best way to do it using XMPP Framework. Using XMPP you can send files & text to other persons. Using it you can record voice message & send it across. There are some links for it:

GitHub Project Link for XMPP Chat

Building a Jabber Client for iOS: XMPP Setup

Hope it helps to you.

EDIT:

Apple's GameKit framework provides evertyhing you need to implement in-game chat.

The full documentation is here:

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/AddingVoiceChattoaMatch/AddingVoiceChattoaMatch.html#//apple_ref/doc/uid/TP40008304-CH11-SW11

Assuming you have allready connected the App to one or more other players using GameKit, you can start the voice chat like so:

-(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;

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!