iPhone(iOS) programming: Get Google Contacts

On July 22, 2013, in iOS, Objective C, by Dipin Krishna

This tutorial walks you through on how to retrieve google contacts programatically using Objective C.

Here,

1. I am going to create a Single View project for the tutorial.
2. Add the GData headers and other required frameworks and libraries.
3. A screen to get the Username and Password.
4. Retrieve Contacts.

1. Create a new Single View project (For beginners).

This is a tutorial, so i am creating a new project to demonstrate what we are trying to achieve.

Next: Add the Gdata headers and other required frameworks and libraries

Pages: 1 2 3 4

Tagged with:  

21 Responses to “iPhone(iOS) programming: Get Google Contacts”

  1. Hitesh H Rajyaguru says:

    Undefined symbols for architecture x86_64:
    “_OBJC_CLASS_$_GDataQueryContact”, referenced from:
    objc-class-ref in MainScreenViewController.o
    “_OBJC_CLASS_$_GDataServiceGoogleContact”, referenced from:
    objc-class-ref in MainScreenViewController.o
    “_kGDataServiceDefaultUser”, referenced from:
    -[MainScreenViewController getGoogleContacts] in MainScreenViewController.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

  2. Mitu says:

    I encountered a problem like it was working perfectly for some mail id’s but for some mail id’s its showing “Authentication Failed”. Please help me out.

  3. shailendra says:

    I did all of the steps, but I’ve encountered some errors:

    1. In ViewController.h at #import “GDataFeedContact.h” and “GDataContacts.h” it says the file can’t be found.

    2. In ViewController.m, at [self getGoogleContacts], [self contactService], and [self setContactFetchTicket:ticket] it says that the “Receiver type ViewController for instance message does not declare a method with selector ..”

    I’m using xcode 5.1.

  4. suleman says:

    Hi there.. its good to see this static library. But having some issue.
    Getting Below error….
    Undefined symbols for architecture armv7:
    “_OBJC_CLASS_$_GTMOAuth2ViewControllerTouch”, referenced from:
    objc-class-ref in EmailHelperManager.o
    objc-class-ref in LoginViewController.o
    ld: symbol(s) not found for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    have you updated the static library for armv7 and armv7s? or it is something else error…?

    Thanks

  5. Bea says:

    Hi! Sorry for sorta flooding your responses. I was wondering if you knew how to get other contact details such as primary address, birthdays, etc?

    Thanks! 🙂

    • Hi,

      You can get the address using the following code:

      GDataStructuredPostalAddress *address = [[contact structuredPostalAddresses] objectAtIndex:0];
      if (address) {
          NSLog(@"formattedAddress   :  %@", [address formattedAddress]);
      }

      You can also use the following if you need the individual elements instead of the ‘formattedAddress’:

      city, countryName, countryCode, houseName, neighborhood, POBox, postCode, region, street, subregion
      • Birthday:

        NSString *dob = @"";
        if ([contact birthday]) {
            dob = [contact birthday];
            NSLog(@"dob   :  %@", dob);
        }
      • Bea says:

        Thank you so much for all the help! One last question, is it possible to get the notes I add in my contacts? I can’t find it/get it in the gdata sources.

      • // Notes
        GDataEntryContent *content = [contact content];
        NSString *notes = @"";
        if (content && [content contentStringValue]) {
            notes = [content contentStringValue];
            NSLog(@"notes   :  %@", notes);
        }
  6. Bea says:

    I got it to work already! THANK YOU SO MUCH FOR THIS TUTORIAL! 😀

  7. Bea says:

    I did all of the steps, but I’ve encountered some errors:

    1. In ViewController.h at #import “GDataFeedContact.h” and “GDataContacts.h” it says the file can’t be found.

    2. In ViewController.m, at [self getGoogleContacts], [self contactService], and [self setContactFetchTicket:ticket] it says that the “Receiver type ViewController for instance message does not declare a method with selector ..”

    I’m using xcode 4.2 cause my mac is only on snow leopard.

    I’m new to xcode, so this tutorial is really appreciated! Thank you for all the help! 🙂

  8. Jitendra Deore says:

    I have used the Login with Gmail in my ios app. when user click with gmail login default gmail login window will be open in webview. where user can write therir username and password. and then after login succeessfully access to main view controller.

    but in you app need to pass the user name and password to get the gmail contact. so how can i do this with my app.

  9. Tristan says:

    This is great, thanks! I was just wondering where you got the GData library (or how you created it)?

Leave a Reply

*

Search