簡體   English   中英

如何使用XMPP框架和Openfire服務器將電話簿聯系人添加到ios中的聊天應用程序中?

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

我是聊天應用程序的新手,並使其成為Objective-C。 我想知道如何將所有電話簿聯系人保存為用戶。 我知道如何從通訊錄中獲取聯系人,但是對xmpp框架和openfire不太了解。如果有人可以幫助我。

首先,您知道如何獲取聯系人。現在,您需要添加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]; 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];

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM