繁体   English   中英

如何在XMPP iOS中将用户添加到现有的ROOM?

[英]How to add user to existing ROOM in XMPP iOS?

我在XMPP聊天模块中工作。 我昨天创建了组,现在我想在这个组中添加更多成员。 在现有组中添加成员的过程是什么。

这是我创建组的代码:

XMPPJID *roomJID = [XMPPJID jidWithString:@"xyz@conference.abc"];
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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM