简体   繁体   English

如何使用XMPP框架和Openfire服务器将电话簿联系人添加到ios中的聊天应用程序中?

[英]How could i add phonebook contacts to my chat app in ios by using xmpp framework and openfire server?

I am new to chat application and making it in objective-c. 我是聊天应用程序的新手,并使其成为Objective-C。 I wanted to know how could i save all my phonebook contacts as user. 我想知道如何将所有电话簿联系人保存为用户。 i know how to fetch contacts from address book but dont have much idea about xmpp framework and openfire.If anyone could help me. 我知道如何从通讯录中获取联系人,但是对xmpp框架和openfire不太了解。如果有人可以帮助我。

First you know how to fetch contacts.now every contact you need to add Xmpp Roaster.like below call this method called at your contact fetching class. 首先,您知道如何获取联系人。现在,您需要添加Xmpp Roaster的每个联系人。如下所示,在您的联系人获取类中调用此方法。

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

in your xmpp class follow below code to add to roster 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]; 在您的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]; 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];

hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM