本文介绍了XMPPFramework - 如何获取在线和离线好友列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 iOS 中使用 XMPPFramework 获取在线和离线好友列表?
How can I get a list of online and offline friends using XMPPFramework in iOS?
我想向用户发送好友请求.那么我怎样才能做到这一点呢?有人可以为我分享一些示例代码吗?
I want to send buddy request to user. So how can I achieve this? Can somebody share some sample codes for me?
谢谢.
推荐答案
通过使用这些方法,您将收到整个用户在线/离线、添加、删除、更新等的通知.通过使用这些方法您可以更新您的联系人列表
By using these methods you will get notified whole a user going to online/ offline, added, removed , updated etc.by using these methods you can update your contact list
- (void)xmppRoster:(XMPPRosterMemoryStorage *)sender didAddUser:(XMPPUserMemoryStorageObject *)user
- (void)xmppRoster:(XMPPRosterMemoryStorage *)sender didUpdateUser:(XMPPUserMemoryStorageObject *)user
- (void)xmppRoster:(XMPPRosterMemoryStorage *)sender didRemoveUser:(XMPPUserMemoryStorageObject *)user
- (void)xmppRoster:(XMPPRosterMemoryStorage *)sender
didAddResource:(XMPPResourceMemoryStorageObject *)resource
withUser:(XMPPUserMemoryStorageObject *)user
- (void)xmppRoster:(XMPPRosterMemoryStorage *)sender
didUpdateResource:(XMPPResourceMemoryStorageObject *)resource
withUser:(XMPPUserMemoryStorageObject *)user
- (void)xmppRoster:(XMPPRosterMemoryStorage *)sender
didRemoveResource:(XMPPResourceMemoryStorageObject *)resource
withUser:(XMPPUserMemoryStorageObject *)user
//添加好友
- (void)addContactWithUserName:(NSString *)userName andNickName:(NSString *)nickName;
{
if(userName)
{
XMPPJID *jid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@",userName,self.hostName]];
if(nickName)
{
[_xmppRoster addUser:jid withNickname:nickName];
}
else
{
[_xmppRoster addUser:jid withNickname:nil];
}
}
else
{
NSLog(@"missing userName");
}
}
这篇关于XMPPFramework - 如何获取在线和离线好友列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!