我已經設置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中使用它。
任何想法,我要去哪裏錯了?
找到任何解決這個問題? –