XMPP房间邀请好友IOS
Posted
技术标签:
【中文标题】XMPP房间邀请好友IOS【英文标题】:XMPP Room Invite Friend IOS 【发布时间】:2013-11-22 06:34:50 【问题描述】:我在 ios 中使用 XMPP 框架。如何邀请其他用户进行群聊?
[xmppRoom1 inviteUser:[XMPPJID jidWithString:@"abc@domain.com"] withMessage:@"Come Join me"];
【问题讨论】:
【参考方案1】:MUC中可以一一邀请多个用户:
for (int contactIndex = 0; contactIndex <contactsToInviteArray.count; contactIndex++)
NSString * inviteUserJID = [NSString stringWithFormat:@"%@@%@",[contactsToInviteArray enter code hereobjectAtIndex:contactIndex], SERVER_NAME];
[xmppRoom1 inviteUser:[XMPPJID jidWithString:inviteUserJID] withMessage:@"Come Join me"];
【讨论】:
在调用邀请函数之前我们是否需要执行此代码。 _xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:xmppRoomCoreDataStorage jid:groupJabId dispatchQueue:dispatch_get_main_queue()]; [_xmppRoom 激活:[[CLXMPPDelegate sharedManager] xmppStream]]; [_xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()]; NSXMLElement *history = [NSXMLElement elementWithName:@"history"]; [history addAttributeWithName:@"maxstanzas" stringValue:@"0"]; [_xmppRoom joinRoomUsingNickname:userMO.closrr_id history:nil];【参考方案2】:此代码对我有用。
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:[XMPPJID jidWithString:@"Groupname"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom inviteUser:[XMPPJID jidWithString:@""] withMessage:[NSString stringWithFormat:@"Come Join me"] listusers:@" array with list of users JID "];
【讨论】:
以上是关于XMPP房间邀请好友IOS的主要内容,如果未能解决你的问题,请参考以下文章
XMPP群聊java - 在邀请监听器内加入房间的用户的逻辑不起作用
检索 Facebook 好友并邀请他们加入我的 iOS 应用