【问题标题】:How to implement voice & text chat between two iOS device如何在两个 iOS 设备之间实现语音和文本聊天
【发布时间】:2012-10-26 08:59:08
【问题描述】:

我想实现一个应用程序,通过该应用程序可以在网络下的两个 iOS 设备之间进行语音和文本聊天。我不需要像 LinPhone 或 SiPhone 这样的任何电话的语音通话功能。我研究过它们,发现对我来说太复杂了。有没有什么简单的 SDK 可以做到这一点???

顺便说一句,用户识别可以通过电子邮件验证来完成......

【问题讨论】:

    标签: objective-c ios text chat voice


    【解决方案1】:

    我认为最好的方法是使用 XMPP 框架。使用 XMPP,您可以将文件和文本发送给其他人。使用它,您可以录制语音消息并将其发送出去。有一些链接:

    GitHub Project Link for XMPP Chat

    Building a Jabber Client for iOS: XMPP Setup

    希望对你有帮助。

    编辑:

    Apple 的 GameKit 框架提供了实现游戏内聊天所需的一切。

    完整的文档在这里:

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

    假设您已经使用 GameKit 将应用程序连接到一个或多个其他玩家,您可以像这样开始语音聊天:

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

    【讨论】:

    • 感谢您的回复。我查看了您的链接,想知道它们是否支持语音??
    • 不,不支持语音。但也许您可以构建一个逻辑以在文件中发送录音,反之亦然。
    • 也检查一下。我也添加了一个 GameKit 方法来发送语音。
    猜你喜欢
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    • 2014-12-07
    • 2011-01-11
    • 1970-01-01
    • 2010-12-04
    • 2012-05-16
    • 1970-01-01
    相关资源
    最近更新 更多