Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to filter the XMPP presence that is received in iOS?
    text
    copied!<p>I am successfully able to receive presence i.e. status of users in my iOS XMPP client. But within that status is some extra info that I wish to extract. This info was added as a child to the presence while sending.</p> <p>Here is how I extended presence while sending:</p> <pre><code>- (void)updatePresence:(NSNotification *)notification { XMPPPresence *presence = [XMPPPresence presence]; NSString *string = [notification object]; // object contains some random string. NSXMLElement *status = [NSXMLElement elementWithName:@"status" stringValue:string]; [presence addChild:status]; NSLog(@"presence info :- %@",presence); [[self xmppStream] sendElement:presence]; } </code></pre> <p>Now when I am receiving presence I want to retrieve this extended portion of the presence. How can it be done?</p> <p>This is how I receive the presence:</p> <pre><code>- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence { NSString *presenceType = [presence type]; // online / offline NSString *myUsername = [[sender myJID] user]; NSString *presenceFromUser = [[presence from] user]; NSString *presenceString=[presence fromStr]; NSString *string = @"@company.com"; if ([presenceString rangeOfString:string].location == NSNotFound) { if (![presenceFromUser isEqualToString:myUsername]) { if ([presenceType isEqualToString:@"available"]) { NSMutableDictionary *buddy=[[NSMutableDictionary alloc]init]; [buddy setObject:presenceFromUser forKey:@"name"]; [buddy setObject:[presence fromStr] forKey:@"jid"]; [_chatDelegate newBuddyOnline:buddy]; } else if ([presenceType isEqualToString:@"unavailable"]) { NSMutableDictionary *buddy=[[NSMutableDictionary alloc]init]; [buddy setObject:presenceFromUser forKey:@"name"]; [buddy setObject:[presence fromStr] forKey:@"jid"]; [_chatDelegate buddyWentOffline:buddy]; } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload