我已经设置ClientID的,范围,然后在MyViewController按一下按钮,我打电话从LoginCLass其工作方法登录,但之后[登入验证],委托执行finishedWithAuth是没有得到所谓后不叫。我已经设置的.h文件finishedWithAuth身份验证方法
- (NSError *) login
{
NSLog(@"In login :%@ %@ %@",kClientId,scopes,actions);
if(!kClientId|| !scopes)
{
NSLog(@"Either client ID Or scope is not specified!! ");
NSError *err=[[NSError alloc]initWithDomain:@"Scope not specified" code:0 userInfo:nil];
return err;
}
else
{
NSLog(@"Client ID and Scope are set.");
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
signIn.shouldFetchGooglePlusUser = YES;
[signIn authenticate];
[signIn trySilentAuthentication];
return nil;
}
}
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
NSLog(@"Received error %@ and auth object %@",error, auth);
}
以及在AppDelegate中我加入代码
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
我已经检查到指定的包ID和URL类型,它们被设置为相同ID捆绑来自Google API访问权限。
这些方法在LoginClass其在MyViewController类使用。
当我将finishedWithAuth委托设置为MyViewController时,通过将其设置为GPPSignInDelegate,代码运行良好。但是,我想从LoginClass中使用它。
任何想法,我要去哪里错了?
找到任何解决这个问题? –