Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:30:05+00:00 2026-06-05T14:30:05+00:00

I am developing an iOS XMPP chat app that utilizes Robbie Hanson’s XMPPFramework. The

  • 0

I am developing an iOS XMPP chat app that utilizes Robbie Hanson’s XMPPFramework.

The most important functionalities have been implemented – sending and receiving messages. Basically, I’ve built a basic functional chat app already, with a little eye candy of course.

Now, the problem I have is regarding MUC. The codes I saw from other websites show that there is a method initWithRoomName in XMPPRoom. However, this method is absent in the git repo I cloned. So, what is the alternative to this? Or, if there is none, how do I go about creating rooms using XMPPFramework?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:30:07+00:00Added an answer on June 5, 2026 at 2:30 pm

    Below is how I got my own problem solved. Note that this solution does not involve XMPPRoom at all. First, I created a method that, depending on the situation, either creates or enters a room. (Per XMPP documentation, the XML request for creating is the same is the same as the one you would send to enter a room; that is, if the room has does not exist yet when you enter it, the service will create it for you.)

    Here we go. This is the method that creates/enters a room. What this method does is send a presence to the room which you intend to create/enter. If you are the first to enter a room and the room has not been created yet, you automatically become its owner and moderator.

    - (void)createOrEnterRoom:(NSString *)roomName
    {
    //here we enter a room, or if the room does not yet exist, this method creates it
    //per XMPP documentation: "If the room does not yet exist, the service SHOULD create the room"
    //this method accepts an argument which is what you would baptize the room you wish created
    NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
    NSString *room = [roomName stringByAppendingString:@"@conference.jabber.com/iMac"];
    [presence addAttributeWithName:@"to" stringValue:room];
     NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
    NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
     [history addAttributeWithName:@"maxstanzas" stringValue:@"50"];
     [x addChild:history];
     [presence addChild:x];
     [[self xmppStream] sendElement:presence];
    }
    

    Next, in the AppDelegate where XMPPStream methods are declared we filter the XML response we receive in the didReceivePresence method by checking the status code sent by the server. If the status code is 201, bingo! The room creation went just fine. Status codes other than 201 mean different things, but let’s focus on 201 for our purpose.

    - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
    {
         NSXMLElement *x = [presence elementForName:@"x" xmlns:@"http://jabber.org/protocol/muc#user"];
        for (NSXMLElement *status in [x elementsForName:@"status"])
        {
            switch ([status attributeIntValueForName:@"code"])
            {
                case 201: [self notifyRoomCreationOk:room];
            }
        }
     }
    

    Then, we tell the server that what we are creating a room of the type “instant,” which means that we will send an IQ element telling it room defaults. notifyRoomCreationOk is a delegate method called in a different view when the room creation succeeds, after all I have to record the room in a text file to make it persistent so that the next time I open the app the room I created before will be visible. In my notifyRoomCreationOk method, I have sendDefaultRoomConfig which, basically, describes what is stated in the first sentence of this paragraph.

    -(void)sendDefaultRoomConfig:(NSString *)room
    {
    NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"jabber:x:data"];
    [x addAttributeWithName:@"type" stringValue:@"submit"];
    NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/muc#owner"];
    [query addChild:x];
    XMPPIQ *iq = [XMPPIQ iq];
    [iq addAttributeWithName:@"id" stringValue:[NSString stringWithFormat:@"inroom-cr%@", room]];
    [iq addAttributeWithName:@"to" stringValue:room];
    [iq addAttributeWithName:@"type" stringValue:@"set"];
    [iq addChild:query];
    [[self xmppStream ] sendElement:iq];
    }
    

    Make sure that you have XMPPStream enabled on the views that call the above methods, otherwise, these won’t work. That’s all there is to it. Have fun XMPP-ing!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a XMPP based chat application for iOS. One of the features
I'm developing an iOS app using Core Plot headers. I have different UI for
I am developing an IOS app. I need a functionality that includes undo and
I'm developing an iOS app with XCode 4.2 and latest SDK. I have added
We developing a iOS app that uses CoreData. To keep ourselves from going crazy
I am developing an iOS app using XCode 4.2 I have a UIImage variable
I am developing a XMPP based chat client for iOS. One of the requirements
Developing ios app. I have an object class Product.h and .m respectively along with
I'm developing an IOS app that creates files on the device, e.g. with NSKeyedArchiver
I'm developing an iOS app that includes support for OpenFeint. OpenFeint includes support for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.