Need a solution to implement xmpp add friends in group chat and sending message to them in once in ios

I'm having difficulties to add friends, sending invitations and also in group chat like sending one message for all using xmpp. i know that I need to use XEP-0045. But I am not succeeded. Can anybody tell me how to do it.

  1. Send friend request for one to one chat.
  2. send invitation to join chat room.
  3. send message to chat room's friends.

if somebody has sample code that would be great..

Thanks in advance

Answers


for #3 : send message to chat room's friends.

-(void) sendGroupMessage:(NSString *) groupJID Message:(NSString *)msg{

    XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.%@",groupJID,SERVER_URL]];

    XMPPRoom *muc = [[XMPPRoom alloc] initWithRoomStorage:xmppRoomStorage jid:roomJID
                                            dispatchQueue:dispatch_get_main_queue()];

    [muc   activate:xmppStream];

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

    [muc   sendMessageWithBody:msg];

}

Point 2: Send invitation to join chat room.

You can send invitation to others when you get the response in following delegate (xmppRoomDidCreate):

- (void)xmppRoomDidCreate:(XMPPRoom *)xmppRoom
{
    NSLog(@"xmppRoomDidCreate");
    [xmppRoom inviteUser:[User JID Here] withMessage:@"Your Message Here"];
    // You can send invitations in loop if you have multiple users to invite
}

Point 3: Send message to chat room's friends. Actually the message is broadcasted in group. Surely shall be delivered to all members in group.

- (void) sendMessageInGroup:(NSString *) message withGroupName:(NSString *) groupName
{
    NSString * qualifiedGroupName = [NSString stringWithFormat:@"%@@%@", [groupName lowercaseString], SERVER_NAME];

    //      self.xmppRoomDetails consists of your muc rooms' objects i.i XMPPRoom
    for (int i = 0; i < self.xmppRoomDetails.count; i++)
    {

        XMPPRoom * room = [self.xmppRoomDetails objectAtIndex:i];
        XMPPJID * myRoomJID = room.myRoomJID;
        NSString * roomName = [NSString stringWithFormat:@"%@@%@", [myRoomJID.user lowercaseString], SERVER_NAME];

        if ([qualifiedGroupName rangeOfString:roomName].location != NSNotFound)
        {
            XMPPRoom * sendMessageWithRoom = [self.xmppRoomDetails objectAtIndex:i];
            [sendMessageWithRoom sendMessage:message];
        }

     }
 }

Need Your Help

Laravel returns json data in different way on local and Amazon EC2

php json laravel amazon-web-services amazon-ec2

We are using Laravel as back end and Angular JS for our front end REST application

Get Current Page number of Embedded pdf

javascript jquery html pdf iframe

I am planning to develop a webapp. The page will have an iframe on the left side and javascript form on right side. The iframe will be used to view pdfs from server.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.