Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xmpp IOS multiuser chat . i didnot find a way to accept the invitation from group ? how i can accept the incomming invitation

When I send an invitation this function is called, but I can't understand what line of code I should use for accept invitation.

I am trying to create a multi user and multi groups invitation also called did received message function.

- (void)xmppMUC:(XMPPMUC *) sender roomJID:(XMPPJID *) roomJID didReceiveInvitation:(XMPPMessage *)message 
{ 
}
like image 723
Shahbaz Ali Avatar asked Nov 27 '25 05:11

Shahbaz Ali


1 Answers

This is how you can accept the group invitation. You just need to activate your XMPPMUC protocol as below:

XMPPMUC * xmppMUC = [[XMPPMUC alloc] initWithDispatchQueue:dispatch_get_main_queue()];
[xmppMUC   activate:_xmppStream];
[xmppMUC addDelegate:self delegateQueue:dispatch_get_main_queue()];

To accept incoming invitation for MUC:

- (void)xmppMUC:(XMPPMUC *)sender didReceiveRoomInvitation:(XMPPMessage *)message
{
    NSXMLElement * x = [message elementForName:@"x" xmlns:XMPPMUCUserNamespace];
    NSXMLElement * invite  = [x elementForName:@"invite"];
    if (!isEmpty(invite))
    {
        NSString * conferenceRoomJID = [[message attributeForName:@"from"] stringValue];
        [self joinMultiUserChatRoom:conferenceRoomJID];

    }
}

- (void) joinMultiUserChatRoom:(NSString *) newRoomName
{
    XMPPJID *roomJID = [XMPPJID jidWithString:newRoomName];
    XMPPRoomMemoryStorage *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()];
    [xmppRoom joinRoomUsingNickname:@"YOUR NICKNAME" history:nil];
}
like image 142
Fatima Arshad Avatar answered Nov 29 '25 18:11

Fatima Arshad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!