0

I read the below link and now I understood that I need to make an api call to fetch the contacts. As I am new to Swift3 could someone guide me how to do this. I read somewhere that Almofire and Swifty json would help and I also read GData also will help. I am little confused. Please guide me.

Google Contacts API

Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91
Dee
  • 1,887
  • 19
  • 47
  • https://stackoverflow.com/questions/40163529/integrate-google-contacts-api-into-my-swift-3-app/54710237#54710237 – Naresh Feb 15 '19 at 13:25

2 Answers2

0

You might want to try Google Sign-In for iOS, get users into your apps quickly and securely, using a registration system they already use and trust—their Google account. This Google Sign-in videos - series #1, series #2 and series #3 will help you understand the implementation of Google SignIn in iOS, how do you use Google Sign in on iOS with another service like Google Drive? and more.

Here are some tutorials and reference that can help:

Lastly here are some related SO question for refrence - How to fetch gmail Contacts in iOS application using google contacts api? and Get Google contacts using API on iOS

Hope this helps.

Community
  • 1
  • 1
Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91
  • Thanks for the links and information. It helped a lot but I am still unable to fetch the contacts into my application. – Dee Nov 07 '16 at 21:27
0

I was actually stuck on this too and couldn't find a solution but I ended up figuring it out. You first need to authenticate with Google Sign In and then pass the accessToken into this endpoint:

let urlString = ("https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=5000&access_token=\(GIDSignIn.sharedInstance().currentUser.authentication.accessToken!)")

        guard let url = URL(string: urlString) else { return }
        URLSession.shared.dataTask(with: url, completionHandler: {
            (data, response, error) in

            if(error != nil){
                print("error")
            }else{
                do{
                    let json = try JSONSerialization.jsonObject(with: data!, options:[]) as! [String : AnyObject]
                    //parse JSON

                }catch let error as NSError{
                    print(error)
                }
            }
        }).resume()