【问题标题】:How could i add phonebook contacts to my chat app in ios by using xmpp framework and openfire server?如何使用 xmpp 框架和 openfire 服务器将电话簿联系人添加到 ios 中的聊天应用程序?
【发布时间】:2016-07-26 03:55:20
【问题描述】:

我是聊天应用程序的新手,并在 Objective-c 中制作它。我想知道如何将我所有的电话簿联系人保存为用户。我知道如何从通讯录中获取联系人,但对 xmpp 框架和 openfire 不太了解。如果有人可以帮助我。

【问题讨论】:

  • 对不起,你能告诉我你到目前为止做了什么。我的意思是在这里给我看一些代码。
  • 为了添加用户,我在你的帖子中做了同样的事情,但没有显示在 openfire 服务器中
  • 您将联系人添加到 openfire 的位置。
  • 发送你的邮件ID我会加你

标签: objective-c iphone xmppframework


【解决方案1】:

首先您知道如何获取联系人。现在您需要添加 Xmpp Roaster 的每个联系人。如下所示 调用在您的联系人获取类中调用的此方法。

[[self appDelegate] addNewBuddyToMyAccount:tempNumber withNickName:[[tempContactList objectAtIndex:i] fullname]]; //in my terms tempNumber is the phone number that is JID.

在您的 xmpp 类中,按照以下代码添加到名册 NSString * buddyNameJID = [NSString stringWithFormat:@"%@@serverName",buddyUserID]; XMPPJID *jid = [XMPPJID jidWithString:buddyNameJID]; //if you don't need permission then use below line otherwise comment [[self xmppRoster] acceptPresenceSubscriptionRequestFrom:jid andAddToRoster:YES]; //here we are adding our contact to our roster then check once in roaster in openfire [[self xmppRoster] addUser:jid withNickname:nickName];

希望这会有所帮助。

【讨论】:

  • 感谢您的回复,但我在我的 openfire 服务器中看不到这些联系人.. 我需要在 openfire 服务器上手动添加虚拟用户,然后我必须将它们添加为名册吗?
  • 不需要先连接到 openfire 检查上面的代码是否正常
  • 但代码对我不起作用。我们继续聊天讨论吗?
  • @I_User 是的,来聊天对我来说也很容易
  • 我没有找到你的邮件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-01
  • 2016-01-29
  • 2012-02-12
  • 1970-01-01
  • 2012-10-25
  • 2016-04-03
相关资源
最近更新 更多