如何将用户添加到XMPP iOS中的现有ROOM?
问题描述:
我正在使用XMPP聊天模块。我昨天创建了组,现在我想在此组中添加更多成员。在现有组中添加成员的过程是什么?如何将用户添加到XMPP iOS中的现有ROOM?
这里是我的代码来创建组:
XMPPJID *roomJID = [XMPPJID jidWithString:@"[email protected]"];
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPRoom *newxmppRoom = [[XMPPRoom alloc]
initWithRoomStorage:roomMemoryStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[newxmppRoom activate:xmppStream];
[newxmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[newxmppRoom joinRoomUsingNickname:@"MY_NICKNAME" history:nil];
我应该有每次写上面的代码时,我想在房间添加用户?
答
是的,所有此代码是需要加入一个房间。在回调
XMPPJID * userID = [XMPPJID jidWithString:user.entityID];
[room inviteUser:userID withMessage:@""];
然后:要邀请的用户,则应该使用方法
- (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *)roomJID didReceiveInvitation:(XMPPMessage *)message {
// User your code here to join
}