【iOS XMPP】使用XMPPFramewok(三):好友状态

好友状态

 

获取好友状态,通过实现 

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence

方法

当接收到 <presence /> 标签的内容时,XMPPFramework 框架回调该方法

 

一个 <presence /> 标签的格式一般如下:

<presence from="">

  <show>这里是显示的内容<show />

  <status>这里是显示的状态<status />

<presence />

presence 的状态:

available 上线

away 离开

do not disturb 忙碌

unavailable 下线

 

复制代码
- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {
    NSString *presenceType = [presence type];
    NSString *presenceFromUser = [[presence from] user];
    if (![presenceFromUser isEqualToString:[[sender myJID] user]]) {
        if ([presenceType isEqualToString:@"available"]) {
            //
        } else if ([presenceType isEqualToString:@"unavailable"]) {
            //
        }
    }
}
复制代码

链接: http://www.cnblogs.com/dyingbleed/

你可能感兴趣的:(ios,XMPP)