3
votes

i am developing chat application i want to send the recipient "is typing" when i type a message does any one has idea how to do this using xmpp framework and open fire as server.

below is my code

-(void)sendChatStateNotification: (NSString *)strState
{
     NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
     NSXMLElement *chatStatus=[NSXMLElement elementWithName:strState xmlns:xmlns_chatstates];
    [message addAttributeWithName:@"type" stringValue:@"chat"];
    [message addAttributeWithName:@"to" stringValue:chatWithUser];
    [message addChild:chatStatus];
}

-(void)textViewDidChange:(UITextView *)textView
{
    [self sendChatStateNotification:@"composing"];
}

i am still not getting the notification

1

1 Answers

9
votes

For sending Typing State

NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue: toID];

NSXMLElement *composing = [NSXMLElement elementWithName:@"composing"];
[composing addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/chatstates"];

[message addChild:composing];

[xmppStream sendElement:message];

At Receiving Side

if ([message hasComposingChatState] == YES)

Check this condition and use it proper with your typing indication.