你好,我已经使用 openfire 作为服务器,并且想要发送好友请求,我正在使用以下代码
- (XMPPRoster *)xmppRoster {
return [[self appDelegate] xmppRoster];
}
-(IBAction)SendFriendRequest:(id)sender
{
XMPPJID *newBuddy = [XMPPJID jidWithString:@"test1@192.168.4.21"];
[[[self appDelegate]xmppRoster]addUser:newBuddy withNickname:@"test user 1"];
}
我收到这种类型的日志
<iq xmlns="jabber:client" type="error" to="192.168.4.21/de4fd927"><query xmlns="jabber:iq:roster"><item jid="test1@192.168.4.21" name="test user 3"></item></query><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></not-authorized></error></iq>
我无法向已在 Spark 中记录的“test1”发送请求。
任何帮助将不胜感激!
最佳答案
每个可以与其他实体交换 XMPP 数据包的 XMPP 实体都应该具有 username@domain.tld 形式的 JID,您尝试使用 IP 地址而不是域名,这是可能的,但可能会给出意外错误。
您应该先在服务器上进行身份验证,然后才能与其他人交换数据包。
关于ios - 使用 xmpp 和 openfire 向用户发送好友请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22397942/