Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6130249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:50:10+00:00 2026-05-23T16:50:10+00:00

I have a task to develop the application with phone gap. And retrieve in

  • 0

I have a task to develop the application with phone gap. And retrieve in my application.using javascript.

I want first name,last name,address,photo,home page,email,phone no in my application using phone gap. i have done the following code to retrive them. but i am not getting photo and address in my field.

I have done all code to retrieve the contact in native code. and i am sending it to the javascript file by creating the jsstring object of javascript function.

This is my native implement to read address book data.

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)picker
 shouldContinueAfterSelectingPerson:(ABRecordRef)person
{

    /** Fetch Contact name */
    name = (NSString *)ABRecordCopyCompositeName(person);

    NSLog(@"name:%@",name);

    /** Fetch Mobile number  */
    ABMultiValueRef *phones = (ABMultiValueRef *) ABRecordCopyValue(person, kABPersonPhoneProperty);
    mobile=[[NSString alloc] initWithString:@""];
    NSString *mobileLabel = [[NSString alloc] initWithString:@""];
    for (CFIndex i=0; i < ABMultiValueGetCount(phones); i++) {
        mobileLabel = (NSString *) ABMultiValueCopyLabelAtIndex(phones, i);
        if ([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel]) {
            mobile = (NSString *)ABMultiValueCopyValueAtIndex(phones, i);
        }
        else if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneIPhoneLabel]) {
            mobile = (NSString *)ABMultiValueCopyValueAtIndex(phones, i);
        }
    }

    /** Fetch Email addres */
    emailID =  [NSString stringWithFormat:@""];
    ABMultiValueRef emails = (ABMultiValueRef) ABRecordCopyValue(person, kABPersonEmailProperty);
    for (CFIndex i=0; i < ABMultiValueGetCount(emails); i++) {

        [emailID release];
        emailID = (NSString *)ABMultiValueCopyValueAtIndex(emails, 0);  
        NSLog(@"emailid:%@",emailID);
    }


    /** Fetch Homepage */
    ABMultiValueRef homepage = (ABMultiValueRef *) ABRecordCopyValue(person, kABPersonURLProperty);
    NSString *homepageLabel =  [NSString stringWithFormat:@""];
    homepageID =  [NSString stringWithFormat:@""];
    for(CFIndex i=0; i < ABMultiValueGetCount(homepage);i++)
    {
        homepageLabel = (NSString *) ABMultiValueCopyLabelAtIndex(homepage, i);
        if([homepageLabel isEqualToString:(NSString *)kABPersonHomePageLabel]){
            homepageID = (NSString *)ABMultiValueCopyValueAtIndex(homepage, i);
            NSLog(@"homepage:%@",homepageID);
        }
    }

    /** Fatch Image */
    NSData  *imgData = (NSData *)ABPersonCopyImageData(person);

    // call the js to fill the all contact infromation
    {
        NSString* jsString = [[NSString alloc] initWithFormat:@"fillContactInfo('%@','%@','%@','%@','%@');",name ,mobile ,emailID, homepageID, imgData];
        NSLog(@"jstring:%@",jsString);

        [webView stringByEvaluatingJavaScriptFromString:jsString];
        [jsString release];
    }

    [emailID release];
    [mobile release];
    [mobileLabel release];
    [homepageID release];
    [homepageLabel release];
    return YES;
}


- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)picker shouldContinueAfterSelectingPerson:(ABRecordRef)person
                        property:(ABPropertyID)property
        identifier:(ABMultiValueIdentifier)identifier{

            /*
            * Set up an ABMultiValue to hold the address values; copy from address
            * book record.
            */
            ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonAddressProperty);
            // Set up an NSArray and copy the values in.
            NSArray *theArray = [(id)ABMultiValueCopyArrayOfAllValues(multi) autorelease];
            // Figure out which values we want and store the index.
            const NSUInteger theIndex = ABMultiValueGetIndexForIdentifier(multi, identifier);
            // Set up an NSDictionary to hold the contents of the array.
            NSDictionary *theDict = [theArray objectAtIndex:theIndex];
            // Set up NSStrings to hold keys and values.  First, how many are there?
            const NSUInteger theCount = [theDict count];
            NSString *keys[theCount];
            NSString *values[theCount];
            // Get the keys and values from the CFDictionary.  Note that because
            // we're using the "GetKeysAndValues" function, you don't need to
            // release keys or values.  It's the "Get Rule" and only applies to
            // CoreFoundation objects.
            [theDict getObjects:values andKeys:keys];
            // Set the address label's text.

            addressid = [NSString stringWithFormat:@"%@, %@",
                [theDict objectForKey:(NSString *)kABPersonAddressStreetKey],
                [theDict objectForKey:(NSString *)kABPersonAddressCityKey]];


    // call the js to fill the all contact infromation
    {
        NSString* jsString = [[NSString alloc] initWithFormat:@"fillContactAddress('%@');",addressid];

        NSLog(@"jscript:%@",jsString);

        [webView stringByEvaluatingJavaScriptFromString:jsString];
        [jsString release];
    }

    [[self appViewController] dismissModalViewControllerAnimated:YES];

        // If they didn't pick an address, return YES here to keep going.
        return NO;


}

At this point i am getting the name,address,phone number,email address,home page,photo in NSLog console when i run the application. Following is my javascript function to retrive them:

function fillContactInfo(name,mobile,email,homepage,imgData){

    mobile = mobile.replace(" ", "").replace("(", "").replace(")", "").replace("-", "").replace("+", "").replace("-", "").replace("-", "");

    user.contactname = name;
    user.contactemail = email;
    user.contactphone = mobile;
    user.contactimage = imgData;
    user.contacturl = homepage;

    document.getElementById("contactname").value = user.contactname;        
    document.getElementById("contactemail").value = user.contactemail;
    document.getElementById("contactphone").value = user.contactphone;
    document.getElementById("contactimage").src = "data:image/png;base64,user.contactimage";
    document.getElementById("contacturl").value = user.contacturl;

}


function fillContactAddress(address){

    user.address = address;

    document.getElementById("contactaddress").value = user.contactaddress;

}

In the above code I have develop to retrive the contact in my application. But when i run the application at that time i only get name, email, phone number, and home page in my view. but i cant get address, and photo in my view.

I also have try to put the name, phone number, email, and home page in the

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)picker shouldContinueAfterSelectingPerson:(ABRecordRef)person
                            property:(ABPropertyID)property
            identifier:(ABMultiValueIdentifier)identifier

class method but it is not giving me result.

And I have html image tag to display image of the contact list.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:50:11+00:00Added an answer on May 23, 2026 at 4:50 pm

    The content of address inside the ABMultiValue is a NSDictionary structure. You can use the following keys to retrieve desired values. The detail is in this official document.

    • const CFStringRef kABPersonAddressStreetKey;
    • const CFStringRef kABPersonAddressCityKey;
    • const CFStringRef kABPersonAddressStateKey;
    • const CFStringRef kABPersonAddressZIPKey;
    • const CFStringRef kABPersonAddressCountryKey;
    • const CFStringRef kABPersonAddressCountryCodeKey;

    About image data, I cannot get a clear picture about how it will be processed in javascript. Maybe you need to transfer those binary data with base64 manner.

    Edit:

    An address example:

      ABMultiValueRef aMulti = ABRecordCopyValue(srcRecord, kABPersonAddressProperty);
      if (aMulti != nil) {
         int aMultiCount = ABMultiValueGetCount(aMulti);
         for (int i = 0; i < aMultiCount; ++i) {
             NSDictionary *abDict = (NSDictionary *)ABMultiValueCopyValueAtIndex(aMulti, i); 
    
             NSString *street = [abDict objectForKey:(NSString *)kABPersonAddressStreetKey];
             NSString *city = [abDict objectForKey:(NSString *)kABPersonAddressCityKey];
    
             // obtains other properties ....
    
             [abDict release];
         }
         CFRelease(aMulti);
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a task to develop the application related to address and access the
I have a task to develop an electronic phone book in which i have
i am new in blackberry development. and i have task to develop the application
I have a task to develop a rails application following the model for routing.
I need to develop this kind of application, i'm using php and mysql first
I have a task to develop the application, with the help of the SQL
I have a task to develop the application with map kit and web service
I have to develop an application using C#.net that has to be run once
I am new to iPad application development. I have task to develop an application
I have a task to develop the android application with local push notification. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.