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.
2 Answers
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:
- Integrate Google Signin SDK In iOS Application Using Swift
- How to Integrate Google Sign In into Your iOS Apps
- Requesting additional scopes after sign-in
- Invite friends from Gmail (This tutorial use a gmail contact scope rather than the google plus contacts) PS. not an iOS tutorial
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.
-
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
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()

- 1
- 1
- 2