将用户添加到xmpp组或muc

时间:2015-04-15 09:41:57

标签: ios objective-c iphone ios8 xmpp

我想将4个成员(已经是oprefire中的用户)添加到组中。 我想在没有用户许可的情况下添加它们,也不想发送邀请

现在我正在邀请使用此代码的用户:

[sender inviteUser:[XMPPJID jidWithString:@"keithoys"] withMessage:@"Greetings!"];

还有其他方法可以实现这一目标吗?

1 个答案:

答案 0 :(得分:0)

当用户向其他用户发送请求时,将调用以下委托方法:

-(void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *)roomJID didReceiveInvitation:(XMPPMessage *)message{

    roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
    xmppRoom = [[XMPPRoom alloc]
                initWithRoomStorage:roomMemoryStorage
                                jid:roomJID
                      dispatchQueue:dispatch_get_main_queue()];

    [xmppRoom activate:[self xmppStream]];

    [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

    //Now add user to the group directly without prompting them
    [xmppRoom joinRoomUsingNickname:[xmppStream myJID].user history:nil];
}

我只写了代码,如果你需要解释,我会。