2016-12-27 50 views
1

我正在使用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]; 

我應該有每次寫上面的代碼時,我想在房間添加用戶?

回答

0

是的,所有此代碼需要加入一個房間。在回調

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 
} 
相關問題