I am new to chat application and making it in 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.
问题:
回答1:
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.
[[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];
hope this helps.