【问题标题】:manage friends using xmpp in iphone sdk?在 iphone sdk 中使用 xmpp 管理朋友?
【发布时间】:2011-03-31 12:40:08
【问题描述】:

主题: 嗨,我想开发 xmpp 聊天应用程序,到目前为止我已经完成了 xmpp 聊天,即。向在线用户发送和接收消息。但是我怎样才能将另一个在线用户添加为好友/朋友?以及如何从我的朋友列表中删除朋友(使用 xmpp)?以及如何知道有人向我发送了好友请求(在 xmpp 中) 技术:iphone应用程序编程 语言:目标 C

【问题讨论】:

    标签: iphone


    【解决方案1】:

    XMPP 服务器管理您的好友列表(名册管理),因此您必须向 XMPP 服务器发送订阅/取消订阅数据包以添加或删除好友。请参阅 XMPP RFC (rfc-3921) 中的 8.2 部分,了解您必须发送的 XMPP 消息的格式以及您必须处理的服务器响应。

    这里是 XMPP RFC 的链接(参见第 8.2 节)

    http://xmpp.org/rfcs/rfc3921.html

    【讨论】:

    • 但是我怎么能从 xmpp iphone sdk 做这些事情呢?我有 xmpp iphone sdk,我可以发送好友请求并从好友请求中删除,但我无法获取请求通知和对请求的响应,即。接受或拒绝请求.....
    【解决方案2】:

    使用下面的代码发送好友请求。它目前为我工作。用户名和电子邮件 ID 取决于您的 openfire 设置。

    XMPPJID *newBuddy = [XMPPJID jidWithString:@"friendsemailid or username"];

    [xmppRoster addUser:newBuddy withNickname:nil];

    【讨论】:

      【解决方案3】:
      1.You can add a new friend through this code in didReceivePresence delegate
       else if  ([presenceType isEqualToString:@"subscribe"])
              {
                  NSXMLElement *presenceToRequest = [NSXMLElement elementWithName:@"presence"];
                  [presenceToRequest addAttributeWithName:@"type" stringValue:@"subscribed"];
                  [presenceToRequest addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@", [presence fromStr]]];
                  [presenceToRequest addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@", [presence toStr]]];
                  [[self xmppStream] sendElement:presenceToRequest];
              }
      2.You can send friend request through XMPPRoster method
          [xmppRoster addUser:[XMPPJID jidWithString:friendJID] withNickname:friendNickName];
      3.In didReceivePresence delegate you can your friend request either you want to accept or reject a friendrequest.
      
      I hope this information helps you to solve your issues.enter code here
      

      【讨论】:

      • 第3点不太清楚,你能解释更多吗?你能提供一些代码吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-31
      • 2012-10-29
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多