iphone - Extracting contact variables from profile page (phone #, email address, photo) to iOS Phonebook Contact List -
i'd load info user profiles in app, iphone phonebook/contact list.
my app has user profiles contain various attributes person in they're representing, such phone number, name, school, education level, email address, photo, summary of do, interests etc.
what i'd able do, user able extract (with 1 click) contact attributes profile page gets imported iphone contact list.
so example, if liked usera, , wanted add together iphone contact list, able click "add contacts" import of usera's relevant profile info (phone #, email address, street address, url, photo, etc.) , create usera new contact in iphone phonebook.
is possible using iphone's abpeoplepicker api? if so, how go executing (where can reference proper documentation), , limitations/contraints/criteria in can possible?
framework:
#import "addressbook/addressbook.h"
code:
- (void) getlocalcontacts { abaddressbookref addressbook = abaddressbookcreate( ); cfarrayref allpeople = abaddressbookcopyarrayofallpeople( addressbook ); cfindex npeople = abaddressbookgetpersoncount( addressbook ); user *user; nsmutablearray *allcontacts = [[nsmutablearray alloc] init]; ( int = 0; < npeople; i++ ) { abrecordref person = cfarraygetvalueatindex( allpeople, ); abmultivalueref emails = abrecordcopyvalue(person, kabpersonemailproperty); if(abmultivaluegetcount(emails) != 0) { user = [[user alloc] init]; cfstringref fname, lname; fname = abrecordcopyvalue(person, kabpersonfirstnameproperty); lname = abrecordcopyvalue(person, kabpersonlastnameproperty); cfstringref email = abmultivaluecopyvalueatindex(emails, 0); nsdata *imgdata = (nsdata *)abpersoncopyimagedata(person); nsstring *firstname = (nsstring *) fname; nsstring *lastname = (nsstring *) lname; if (firstname.length == 0 && lastname.length != 0){ user.username = lastname; } else if (firstname.length != 0 && lastname.length == 0){ user.username = firstname; } else if (firstname.length == 0 && lastname.length == 0){ user.username = @""; } else if (firstname.length != 0 && lastname.length != 0){ user.username = [nsstring stringwithformat:@"%@ %@", firstname, lastname]; } //user.firstname = (nsstring *) firstname; user.lastname = @""; user.email = (nsstring *) email; user.firstname = (nsstring *) email; user.localimage = [uiimage imagewithdata:imgdata]; [allcontacts addobject:user]; [user release]; } } [datamanager sharedmanager].alllocalusers = allcontacts; [self hidespinner]; }
iphone ios objective-c abpeoplepickerview
No comments:
Post a Comment