2
votes

Following is my code to get people/contacts from google account using GIDSignIn login.

Code:

- (void)setAuthorizerForSignIn:(GIDSignIn *)signIns user:(GIDGoogleUser *)user {
    GTMOAuth2Authentication *auth = [[GTMOAuth2Authentication alloc] init];
    [auth setClientID:signIns.clientID];
    [auth setUserEmail:user.profile.email];
    [auth setUserID:user.userID];
    [auth setAccessToken:user.authentication.accessToken];
    [auth setRefreshToken:user.authentication.refreshToken];
    [auth setExpirationDate: user.authentication.accessTokenExpirationDate];
    appDelegate.authGooglePlus = auth;
    NSString *urlStr = @"https://people.googleapis.com/v1/people/me/connections?pageSize=200";
   NSURL *url = [NSURL URLWithString:urlStr];
   NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
   [request setHTTPMethod:@"GET"];
   auth.scope= @"https://www.googleapis.com/auth/contacts";
   [auth authorizeRequest:request
          completionHandler:^(NSError *error) {
              NSString *output = nil;
              if (error) {
                  output = [error description];
              } else {
                  NSURLResponse *response = nil;
                  NSData *data = [NSURLConnection sendSynchronousRequest:request
                                                       returningResponse:&response
                                                                   error:&error];
                  if (data) {
                      output = [[NSString alloc] initWithData:data  encoding:NSUTF8StringEncoding];
                      NSMutableArray *array = [[output JSONValue] objectForKey:@"connections"];
                      }
                  } else {
                      // fetch failed
                      output = [error description];
                  }
              }
          }];
}

Following is my code to fetch people/contact list, but i am able to get only 7 records not all records, Any idea how to achieve that?

1

1 Answers

0
votes

The Google People API only returns contacts that are in a contact group. So likely the problem is that the other records are "other contacts", which are not in any contact group and thus are not returned.

Currently there is no way to get other contacts from the Google People API.