robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

How to invite user to multi chatroom and grant admin access to other user #640

Open ain1712 opened 8 years ago

ain1712 commented 8 years ago
  1. Im using below code to invite user into a multi chatroom.

XMPPJID memberJid = [XMPPJID jidWithString:@""user123@xmpp.myserver"]; XMPPRoom xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:[XMPPRoomHybridStorage sharedInstance] jid:@"room123@conference.xmpp.myserver"];

[xmppRoom inviteUser:memberJid withMessage:@"invitation from ios"];

However, I did not see any response from my xmpp server. Am I using the correct way? How do I confirmed that my invitation was successfully sent?

  1. How do I grant admin access to other user in the multi chatroom? Which class should I use?
vicky1787 commented 8 years ago

Please use the edititemaffiliations function of XMPp room and the invite call to do the admin affiliation to invited user.

On Monday, 7 December 2015, ain1712 notifications@github.com wrote:

  1. Im using below code to invite user into a multi chatroom.

XMPPJID memberJid = [XMPPJID jidWithString:@""user123@xmpp.myserver javascript:_e(%7B%7D,'cvml','user123@xmpp.myserver');"]; XMPPRoom xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:[XMPPRoomHybridStorage sharedInstance] jid:@" room123@conference.xmpp.myserver javascript:_e(%7B%7D,'cvml','room123@conference.xmpp.myserver');"];

[xmppRoom inviteUser:memberJid withMessage:@"invitation from ios"];

However, I did not see any response from my xmpp server. Am I using the correct way? How do I confirmed that my invitation was successfully sent?

  1. How do I grant admin access to other user in the multi chatroom? Which class should I use?

— Reply to this email directly or view it on GitHub https://github.com/robbiehanson/XMPPFramework/issues/640.

Sent from my iPhone

ain1712 commented 8 years ago

can you help me with some coding?

vicky1787 commented 8 years ago

NSString *JABID = //JID of the number to be invited

XMPPRoom * sender Šinstance for the room

//Invite person with admin affiliation

[sender editRoomPrivileges:@[[XMPPRoom itemWithAffiliation:@"admin"

jid:[XMPPJID jidWithString:JABID]]]];

[sender inviteUser:[XMPPJID jidWithString:JABID] withMessage:@³You are

invited"];

Please consider the impact to the environment before printing this email

This e-mail is confidential and may also be privileged. If you are not the intended recipient, please notify us immediately by replying to this message and then delete it from your system. You should not copy or use it for any purpose, nor disclose its contents to any other person. Thank you.

ain1712 commented 8 years ago

thanks for your feedback. It's working as I can see the invitation sent in my log. However, on the other device, the invitation was never received and

was never invoked. Any idea why is it so?

vicky1787 commented 8 years ago

Check if you have done this in setupstream.

xmppMUC = [[XMPPMUC alloc] initWithDispatchQueue:dispatch_get_main_queue()];

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

Thanks, Regards, Vicky S Dhas

From: ain1712 Reply-To: robbiehanson/XMPPFramework Date: Friday, 11 December 2015 at 3:26 PM To: robbiehanson/XMPPFramework Cc: vickydhas Subject: Re: [XMPPFramework] How to invite user to multi chatroom and grant admin access to other user (#640)

xmppMUC

ain1712 commented 8 years ago

yes, I confirmed it has been done and the delegate properly assigned. it is because the delegate invoked when invitation sent from android device received. only invitation from ios is not received.

vicky1787 commented 8 years ago

Check then if server side is really acknowledging the guy is joined or not, secondly check at the receiver side that he is actually joining and with proper syntax. Thats all is possible.

ain1712 commented 8 years ago

is there any similar method in xmppframework work similarly to Android's Smack library "connection.addPacketListener"?

vicky1787 commented 8 years ago

Ok here is the flow I did in our team project.

Step 1)Initialise a) <XMPPMUCDelegate> observe in class interface b) @property (nonatomic, strong, readonly) XMPPMUC *xmppMUC; c) @synthesize xmppMUC; 2) Setup Stream xmppMUC = [[XMPPMUC alloc] initWithDispatchQueue:dispatch_get_main_queue()]; [xmppMUC addDelegate:self delegateQueue:dispatch_get_main_queue()]; [self.xmppMUC activate:xmppStream];

3) TearDownFunction [self.xmppMUC deactivate]; xmppMUC = nil; 4) Send invites to the members in the JID using Loop We wanted to invite with some affiliations so did this way ` XMPPJID *xmppJID = [XMPPJID jidWithString:jid];

    //Invite person with admin affiliation and owner to be shown as admin on group info screen
    [_xmppRoom editRoomPrivileges:@[[XMPPRoom itemWithAffiliation:@"member" jid:xmppJID]]];
    [_xmppRoom inviteUser:xmppJID withMessage:[NSString stringWithFormat:@"%@",group_name]];`

4) Step 4 : Observer the a) `- (void)xmppMUC:(XMPPMUC )sender roomJID:(XMPPJID )roomJID didReceiveInvitation:(XMPPMessage )message { NSXMLElement * x = [message elementForName:@"x" xmlns:XMPPMUCUserNamespace]; NSXMLElement * invite = [x elementForName:@"invite"]; NSXMLElement \ directInvite = [message elementForName:@"x" xmlns:@"jabber:x:conference"];

if (invite || directInvite)
{

} }'

b) - (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *)roomJID didReceiveInvitationDecline:(XMPPMessage *)message { //Remove this member from the group, In our application we will accept it and never decline }

Thats all ..the Listener above like smack are these two functions.

ain1712 commented 8 years ago

Thanks for your sharing! After implement it, I received the following

invitation from ios

in

What does it mean by "not-allowed"? Any idea what went wrong? I sent the invitation exactly like what you did in your code.

vicky1787 commented 8 years ago

It means either that you are not having that Privledge as moderator or admin or owner. Or another option is that the room is not configured with configuration allow members to invite other users flag set to 1. Please read xep 0045 for sending configuration. And you should see the configuration for existing in did fetch configuration or settled configuration in did configure callback.

Sent from Outlook Mobile

On Sat, Dec 19, 2015 at 9:04 AM -0800, "ain1712" notifications@github.com wrote:

Thanks for your sharing!

After implement it, I received the following

invitation from ios

in

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

What does it mean by "not-allowed"? Any idea what went wrong? I sent the invitation exactly like what you did in your code.

— Reply to this email directly or view it on GitHub.

shraddha-patel-1891 commented 7 years ago

Hello, i will implement Group exit Functionlity.In this i assign any one member of the group Privilege change member to owner.it's working proper but now 1 group has 2 owners. so how to remove previous owner of the Room? any one have idea then please help me.

Thanks.

bhavesh27691 commented 6 years ago

Hello I am using Xcode 9 and swift 4.0 and I used pod 'XMPPFramework', :git => "https://github.com/robbiehanson/XMPPFramework.git", :branch => 'master' but I got error -->The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.