1

Is there a way to provide user email to GPPSignIn object before calling [self.signIn authenticate]; so user wouldn't have to enter it in browser/Google Plus app to login in using Google account? I want to pass user email to the login form so the user had only to enter the password. I ask user for email earlier, so in most scenarios I can use it to help him login in fewer steps. self.signIn.userEmail is read-only so won't help me much.

1 Answer 1

0

user need to enter email and password if its the first time else doesn't have to.

- (IBAction)Btn_gogleShare:(id)sender {

            if ([[GPPSignIn sharedInstance] authentication]) {
                NSLog(@"share");
                [self GoogleShare];
            } else {
                NSLog(@"Login");
                [self GoogleLogin];

            }
     }

#pragma mark - Google+ ALL ACTIVITY

#pragma mark - Google+ Login

- (void)GoogleLogin{

    GPPSignIn *signIn = [GPPSignIn sharedInstance];
    signIn.shouldFetchGooglePlusUser = YES;
    signIn.shouldFetchGoogleUserEmail = YES;  // Uncomment to get the user's email

    // You previously set kClientId in the "Initialize the Google+ client" step
    signIn.clientID = kClientID;
    signIn.scopes = @[ kGTLAuthScopePlusLogin ];
    //signIn.scopes = @[ @"profile" ];            // "profile" scope

    // Optional: declare signIn.actions, see "app activities"
    signIn.delegate = self;

    [signIn authenticate];

    [self showLoadingView:@"Authorizing..."];

}

- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
                   error: (NSError *) error {
    NSLog(@"Received error %@ and auth object %@",error, auth);
    //  NSLog(@"%@", signIn.authentication.userEmail);
    [self hideLoadingView];

    [self GoogleShare];
}

#pragma mark - Google+ share

- (void)GoogleShare{

    id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];

    // This line will fill out the title, description, and thumbnail from
    // the URL that you are sharing and includes a link to that URL.
    [shareBuilder setURLToShare:[NSURL URLWithString:@"https://www.example.com/restaurant/sf/1234567/"]];

    [shareBuilder open];

}


#pragma mark - Google+ signOut

- (void)signOut {
    [[GPPSignIn sharedInstance] signOut];
}
6
  • I wanted to know if I can pass the user email to the login form so the user had only to enter the password. I wanted to reduce the number of steps that user has to make.
    – KlimczakM
    Apr 16, 2015 at 5:44
  • user email is different for each user so how would it be helpfull. i have found that if user has already login in browser or apps of that cell phone then it will give you option to use it or add next Apr 16, 2015 at 6:02
  • I ask user for his email before, so in most scenarios I can use it.
    – KlimczakM
    Apr 16, 2015 at 6:15
  • Your code is useful but it is not exactly what I am looking for.
    – KlimczakM
    Apr 16, 2015 at 6:20
  • Sorry that i couldnot provide what you want Apr 16, 2015 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.