How to send message using XMPP Framework

后端 未结 4 1291
死守一世寂寞
死守一世寂寞 2020-12-30 10:27

I am creating a chat application using XMPP Framework in iphone. i could get received messages but i am not able to send a message. can any one give me solution for this?? <

4条回答
  •  萌比男神i
    2020-12-30 11:16

    - (void)sendMessage:(NSString *)msgContent
    {
    
        NSString *messageStr = textField.text;
    
        if([messageStr length] > 0)
        {
            NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
            [body setStringValue:messageStr];
    
            NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
            [message addAttributeWithName:@"type" stringValue:@"chat"];
            [message addAttributeWithName:@"to" stringValue:[jid full]];
            [message addChild:body];
    
            [xmppStream sendElement:message];
    
    
    
        }
    }
    

    use the above code in you chatViewcontroller ..it is working fine for me.

提交回复
热议问题