robbiehanson / XMPPFramework

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

xmpp iOS chat client - Implement group chat #260

Open Satishpatel opened 11 years ago

Satishpatel commented 11 years ago

Hello All, I am working on the iOS chat client, can anyone please help me with the multiuser chat. Can anyone please let me know how to get list of group and create group in server with the help of this framework. Is there any document which i can follow for development. Thanks in advance

Ricardo1980 commented 11 years ago

I'm also interested. Thanks.

ObjColumnist commented 11 years ago

I don't think there is any documentation, but the OS X sample app support MUC.

vaiism commented 11 years ago

Hello -

For getting groups - I just attach a NSFetchedResultsController to the XMPPGroupCoreDataStorageObject entity and go from there. This will give you the list of groups as well as the array of users for each group. Something similar to:

       NSEntityDescription *groupsEntity = [NSEntityDescription
entityForName:@"XMPPGroupCoreDataStorageObject" inManagedObjectContext:moc];

        NSSortDescriptor *sortByName = [[NSSortDescriptor alloc]
initWithKey:@"name" ascending:YES];

        if (_groupsFetchRequest == nil) {

            _groupsFetchRequest = [[NSFetchRequest alloc] init];

        }

        [_groupsFetchRequest setEntity:groupsEntity];

        [_groupsFetchRequest setSortDescriptors:[NSArray
arrayWithObject:sortByName]];

        [_groupsFetchRequest setFetchBatchSize:10];

        // Set predicates if needed.

        // Setup the controller.

        // Set the cacheName to nil since we are going to be re-using the
controller

        // with different predicates when the list needs to change.

        _groupsFetchedResultsController = [[NSFetchedResultsController
alloc] initWithFetchRequest:_groupsFetchRequest

  managedObjectContext:moc

    sectionNameKeyPath:nil

              cacheName:nil];

        [_groupsFetchedResultsController setDelegate:self];

        // Fetch.

        NSError *error = nil;

        if (![_groupsFetchedResultsController performFetch:&error]) {

            DDLogError(@"Error performing fetch for groups: %@", error);

        }

HTH.

Satishpatel commented 11 years ago

Thank you very much guys for your comment. I will try and get back to you.

Satishpatel commented 11 years ago

Hello All, I did looked in the OS X sample app but couldn't find the method or anything by which user can create the group. There are the method for create room which is as follows but it didn't get called any time.

Can anyone please let me know how to create room/group. Thanks in advance

RV2013 commented 10 years ago

Hi !

I am newbie to Chat app development for iOS and have been working on this repo for a month.Well, I have found a class called XMPPRoom which implements XEP-0045 (MUC or Group chat protocol extension). I am still not able to get a clue on how to create a room based on that. I am using GTalk chat engine for testing purpose for now.Any help Or advice would be highly appreciated.

Thanks for reading me.

adozenlines commented 10 years ago

Read the header files and configure your server for the auto creation of such rooms but each server is different.

On Jan 17, 2014, at 10:08 AM, RV2013 notifications@github.com wrote:

Hi !

I am newbie to Chat app development for iOS and have been working on this repo for a month.Well, I have found a class called XMPPRoom which implements XEP-0045 (MUC or Group chat protocol extension). I am still not able to get a clue on how to create a room based on that. I am using GTalk chat engine for testing purpose for now.Any help Or advice would be highly appreciated.

Thanks for reading me.

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

Satishpatel commented 10 years ago

Look in the sample code of the mac client. Make sure you change all required parameter which match with your server and it should work.

xieweizhi commented 10 years ago

Hey , did you know how to get list of group by sending XMPPIQ . I did what http://stackoverflow.com/questions/20792739/ios-xmpp-frame-work-xep-0048-bookmark-storage say , but I get 404 result . Help me , please.

vaiism commented 10 years ago

Bookmarks are not for getting groups, but for rooms that you are a part of, and that has to be supported by the server (XEP-0048). If you have a bookmark saved for you on the server, it will come back with you auth request generally, and let you know about auto-invite, etc.

balkrishanyadav commented 10 years ago

Hello I am working on same for group chat . I tried above code but is giving me Roster list not group (muc room)list. Please suggest me a way so i can implement in proper manner(Group operations). Below Example Code:-

NSManagedObjectContext *moc = [appDelegate managedObjectContext_roster];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"XMPPGroupCoreDataStorageObject"//XMPPUserCoreDataStorageObject
                                              inManagedObjectContext:moc];
 NSSortDescriptor *sd1 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
//sectionNum
    NSArray *sortDescriptors = [NSArray arrayWithObjects:sd1, nil];
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    [fetchRequest setEntity:entity];
    [fetchRequest setSortDescriptors:sortDescriptors];
    [fetchRequest setFetchBatchSize:10];
        NSError *error = nil;
        self.arrResult = (NSMutableArray*)[moc executeFetchRequest:fetchRequest error:&error];

    for (int i=0; i<[self.arrResult count]; i++) {
        XMPPGroupCoreDataStorageObject * user =[self.arrResult objectAtIndex:i];
        NSLog(@"user-%@",user.name);
        NSLog(@"user-%@",user.users);

    }
meghaParmar commented 7 years ago

Is there any solution to get MUC list in iOS app using XMPP Framework? I am finding the group list but not giving me MUC details in list

arthtilva commented 7 years ago

You can use following code to get MUC members @meghaParmar `NSString server = [NSString stringWithFormat:@"conference.%@",XMPP_IP]; //or whatever the server address for muc is XMPPJID servrJID = [XMPPJID jidWithString:server];

//servrJID = [xmppRoom roomJID];

XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:servrJID];
[iq addAttributeWithName:@"from" stringValue:[APP_DELEGATE.xmppStream myJID].full];

NSXMLElement *query = [NSXMLElement elementWithName:@"query"];

XMPPMUC *xmppMuc = [[XMPPMUC alloc] init];
[xmppMuc addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppMuc discoverRoomsForServiceNamed:server];

//[xmppMuc discoverRoomsForServiceNamed:@"conference.192.168.1.76"];

[query addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/disco#items"];

[iq addChild:query];
[APP_DELEGATE.xmppStream sendElement:iq];`

OR You can install this plugin in openfire and can use this API.

https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html

LeftRightHand commented 6 years ago

@arthtilva How do I display a profile picture of a chat room member

arthtilva commented 6 years ago

@LeftRightHand either you can use property or manage in your server by API