重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
注释掉就好了。
在曲沃等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站设计制作、网站制作 网站设计制作定制开发,公司网站建设,企业网站建设,成都品牌网站建设,网络营销推广,成都外贸网站建设公司,曲沃网站建设费用合理。
这个是个宏定义的判断,只在MAC OSX10.5以下有效,现在都10.11了,这个注释掉完全不影响,而且你开发的是手机应用,更不影响了。
即时通讯肯定少不了通讯协议,在ios开发中基本上都使用基于XMPP 的协议来做即时通讯。在oc下有封装好的XMPP协议库,你在开发时可以调用XMPP的API来进行开发。通讯的服务器可以用ejabberd来搭建。知道的就这些了
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);
}