我已经完成了google plus集成,我已经完成了一个简单的登录并在桌面上显示谷歌朋友。但问题是在我加载我要检查用户是否登录的朋友之前,所以在我的friendsdisplayViewController中我做过类似的事情
if ([GPPSignIn sharedInstance].authentication)
{
NSLog(@"Status is authenticated, fetching friends!!");
[self fetchGooglePlusFriends:kGTLPlusCollectionVisible];
}
else
{
[[GPPSignIn sharedInstance]authenticate];
}
我已经在初始signupviewcontroller上定义了一个回调函数,在这个下面定义了一个
-(void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
//code
}
但是每当else情况执行时,它总是调用signupviewcontroller上定义的回调函数,而不是我在friendsdisplayViewController上定义的函数,因此我无法显示列表但能够验证身份验证。< / strong>
我只是好奇如何调用这个google回调函数(finishedWithAuth)。为什么它会在注册时调用那个,而不是在friendsdisplay中调用,尽管身份验证是从friendsdisplay触发的。
答案 0 :(得分:0)
我发现问题是因为代理需要放在你正在调用的每个视图控制器上, GPPSignInDelegate。然后,完成的WinAuth将从ViewController触发,你是试图调用它,否则它将触发ViewController中的finishedWithAuth,它位于堆栈顶部。