Question

I've done a google plus integration and i've done a simple login and displaying google friends on table. But the problem is before I load the friends I want to check if the user is logged in, so in my friendsdisplayViewController i've done something like this

if ([GPPSignIn sharedInstance].authentication)
        {
            NSLog(@"Status is authenticated, fetching friends!!");
        [self fetchGooglePlusFriends:kGTLPlusCollectionVisible];
        }
        else
        {

        [[GPPSignIn sharedInstance]authenticate];

        }

I've defined the callback function one on initial signupviewcontroller and one under this one

-(void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
//code
}

But whenever the else case executes it always calls the call back function defined on signupviewcontroller not the one I defined on friendsdisplayViewController hence I'm unable to display the list and but able to validate the authentication.

I'm just curious how the call to this google call back function (finishedWithAuth) is made. Why did it call the one in signup and not in friendsdisplay eventhough the authentication was triggered from friendsdisplay.

Was it helpful?

Solution

I figured out the issue was because of the delegate which needs to be put on every view controller which you are calling, the GPPSignInDelegate. And the finishedWithAuth will then get triggered from the ViewController which you are trying to call it else it will trigger the finishedWithAuth in the ViewController which is standing in top of stack.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top