ios开发之xmpp,ios 应用开发
iOS XMPP怎么实现语音聊天
两种处理方式
南充网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。成都创新互联公司2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司。
1、将获取到的音频文件通过base64加密直接通过xmpp的消息体发送过去,然后解码;
2、通过http请求的方式将音频文件上传到服务器,然后将音频文件的下载地址通过xmpp消息体发送过去,另外一个客户端下载。
音频文件建议转码为amr,这种格式的音频文件比较小。
iOS怎么搭建xmpp聊天
iOS 搭建xmpp聊天的具体步骤如下:
聊天室
[cpp] view plain copy
print?
//初始化聊天室
XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[cpp] view plain copy
print?
//创建聊天室成功
- (void)xmppRoomDidCreate:(XMPPRoom *)sender
{
DDLogInfo(@"%@: %@", THIS_FILE, THIS_METHOD);
}
[cpp] view plain copy
print?
//加入聊天室,使用昵称
[xmppRoom joinRoomUsingNickname:@"quack" history:nil];
[cpp] view plain copy
print?
//获取聊天室信息
- (void)xmppRoomDidJoin:(XMPPRoom *)sender
{
[xmppRoom fetchConfigurationForm];
[xmppRoom fetchBanList];
[xmppRoom fetchMembersList];
[xmppRoom fetchModeratorsList];
}
如果房间存在,会调用委托
[cpp] view plain copy
print?
// 收到禁止名单列表
- (void)xmppRoom:(XMPPRoom *)sender didFetchBanList:(NSArray *)items;
// 收到好友名单列表
- (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items;
// 收到主持人名单列表
- (void)xmppRoom:(XMPPRoom *)sender didFetchModeratorsList:(NSArray *)items;
房间不存在,调用委托
[cpp] view plain copy
print?
- (void)xmppRoom:(XMPPRoom *)sender didNotFetchBanList:(XMPPIQ *)iqError;
- (void)xmppRoom:(XMPPRoom *)sender didNotFetchMembersList:(XMPPIQ *)iqError;
- (void)xmppRoom:(XMPPRoom *)sender didNotFetchModeratorsList:(XMPPIQ *)iqError;
离开房间
[cpp] view plain copy
print?
[xmppRoom deactivate:xmppStream];
[cpp] view plain copy
print?
//离开聊天室
- (void)xmppRoomDidLeave:(XMPPRoom *)sender
{
DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}
其他代理
[cpp] view plain copy
print?
//新人加入群聊
- (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID
{
DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}
//有人退出群聊
- (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID
{
DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}
//有人在群里发言
- (void)xmppRoom:(XMPPRoom *)sender didReceiveMessage:(XMPPMessage *)message fromOccupant:(XMPPJID *)occupantJID
{
DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}
ios 开发升级X-code 7 以后使用XMPP的时候报错
注释掉就好了。
这个是个宏定义的判断,只在MAC OSX10.5以下有效,现在都10.11了,这个注释掉完全不影响,而且你开发的是手机应用,更不影响了。
标题名称:ios开发之xmpp,ios 应用开发
当前网址:http://pwwzsj.com/article/dsgjchh.html