Last online status using XMPP and iOS sdk
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.
Here you will get the last seen Dictionary
For such more Blogs you can visit to http://findnerd.com/NerdDigest
- -(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:@"[email protected]"];
- [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"]};
- }
For such more Blogs you can visit to http://findnerd.com/NerdDigest