简体   繁体   English

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

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

I am working in XMPP chat module. 我在XMPP聊天模块中工作。 I have created group yesterday, Now I want to add some more member in this group. 我昨天创建了组,现在我想在这个组中添加更多成员。 What will be the process to add member in existing group. 在现有组中添加成员的过程是什么。

Here is my code to create group: 这是我创建组的代码:

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];

Should I have to write above code every time when I want to add user in room? 每当我想在房间里添加用户时,我是否应该编写上面的代码?

Yes, all this code is required to join a room. 是的,所有这些代码需要加入一个房间。 To invite a user, you should use the method: 要邀请用户,您应该使用以下方法:

XMPPJID * userID = [XMPPJID jidWithString:user.entityID];
[room inviteUser:userID withMessage:@""];

Then in the callback: 然后在回调中:

- (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