Accepting chatroom invitation

孤人 提交于 2019-11-28 18:59:16

For room invitations and declines, implement XMPPMUCDelegate and its methods -xmppMUC:didReceiveRoomInvitation: and -xmppMUC:didReceiveRoomInvitationDecline:.

To get the room JID, invoke [message from];

To join the room, instantiate an XMPPRoom and invoke -joinRoomUsingNickname:history:.

Then have your room delegate class implement XMPPRoomDelegate, and implement some of the delegate methods to handle receiving messages in the room.

It looks like there isn't at present a more automatic way to respond to invitations.

Update: The delegate callbacks now receive the room JID as a parameter, clarifying the semantics a bit.

- (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *) roomJID didReceiveInvitation:(XMPPMessage *)message;
- (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *) roomJID didReceiveInvitationDecline:(XMPPMessage *)message;
Awais Mobeen

just add below code

if  ([presenceType isEqualToString:@"subscribe"]) {

     [_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"localhost"]];
     NSLog(@"presence user wants to subscribe %@",presenceFromUser);

     [xmppRoster acceptPresenceSubscriptionRequestFrom:[presence from] andAddToRoster:YES];

 //For reject button
//     [xmppRoster rejectPresenceSubscriptionRequestFrom:[tmpPresence from]];          
}

inside the method

 - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence ;
method
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!