If you are using xmpp server for live chat messaging and want to know how to get the last online status of your friend. Then use the following method and you will get the dictionary in xmpp delegates method.
-(void)getlasttimeActivity:(NSString*)userId
{
XMPPJID *touse= [XMPPJID jidWithString:userId];
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:touse];
[iq addAttributeWithName:@"id" stringValue:@"last"];
//[iq addAttributeWithName:@"from" stringValue:@"sumeet@app.kinkey.com.au"];
[iq addAttributeWithName:@"from" stringValue:[xmppStream myJID].full];
NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
[query addAttributeWithName:@"xmlns" stringValue:@"jabber:iq:last"];
[iq addChild:query];
NSLog(@"checking IQ==%@",iq);
[xmppStream sendElement:iq];
}
Here you will get the last seen Dictionary
-(BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{
NSDictionary *LastseenDict=@{@"userId":[iq from].user,@"lastSeenSec":[[iq childElement] attributeStringValueForName:@"seconds"]};
}
1 Comment(s)