[英]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.