如何在iOS中使用XMPPFramework获取在线和离线朋友列表?
我想向用户发送好友请求。那我该怎么做呢?有人可以为我分享一些示例代码吗?
谢谢。
答案 0 :(得分:3)
通过使用这些方法,您将收到整个用户进入在线/离线,添加,删除,更新等的通知,使用这些方法可以更新您的联系人列表
- (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");
}
}