2015-04-08 40 views
0

我想在我的iOS 7應用程序中使用谷歌加API,但它不工作。 我寫入appdelegate.m文件這樣的:谷歌加登錄不工作在iOS 7

static NSString *const kClientId = @"XXXX.apps.googleusercontent.com"; 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 

[GPPSignIn sharedInstance].clientID = kClientId;} 
- (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation { 
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];} 

在我的ViewController我寫了這個:

- (void) loginWithGooglePlus{ 
GPPSignIn *signIn = [GPPSignIn sharedInstance]; 
signIn.shouldFetchGoogleUserID = YES; 
signIn.shouldFetchGooglePlusUser = YES; 
signIn.shouldFetchGoogleUserEmail = YES; 
[signIn setScopes:[NSArray arrayWithObject: @"https://www.googleapis.com/auth/plus.login"]]; 
//signIn.scopes = @[kGTLAuthScopePlusUserinfoEmail]; 
[signIn setDelegate:self]; 
//signIn.delegate = self; 

NSLog(@"started g+ login"); 
[signIn authentication]; 
//[signIn trySilentAuthentication]; 
[self reportAuthStatus];} 
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error: (NSError *) error { 
if (error) { 
    NSLog(@"Status: Authentication error: %@", error); 
    return; 
} else { 
    NSLog(@"Success!"); 
} 
//[self reportAuthStatus];} 
- (void)reportAuthStatus { 
if ([GPPSignIn sharedInstance].authentication) { 
    NSLog(@"Status: Authenticated"); 
} else { 
    // To authenticate, use Google+ sign-in button. 
    NSLog(@"Status: Not authenticated"); 
}} 

而我的問題是,finishedWithAuth回調方法永遠不會運行。我不知道什麼是錯的。

+0

只使用G +集成還是更喜歡FB ..你可以找到更多的計算器? –

+0

你設置了'GPPSignIndelegate' –

+0

我使用fb,twitter,並且想要g +,而且我設置GPPSignIndelegate – just

回答

1

我沒有足夠的聲望發表評論。但是我想說的是,我的應用程序上次被從appstore拒絕說Google+ Google+身份驗證登錄將用於身份驗證。您可以搜索並查看這是一個常見問題。

這是我從蘋果商店裏得到的消息:「我們發現你的應用程序的用戶界面以下問題:應用程序打開移動Safari瀏覽器的網頁創建一個帳戶或登錄,然後返回用戶到應用程序,用戶應該能夠創建一個帳戶或登錄,而無需首先打開Safari。「

Google+登錄會打開Safari登錄,這是不支持的apple.I刪除了谷歌+登錄,然後我的我的應用程序被appstore接受。

做一個關於這個問題的研究。祝你好運,不要浪費時間。

看到thisthis

+0

非常感謝您提供這方面的信息! – just

+0

歡迎你:):我嘗試了另一種方式來在應用程序中進行身份驗證。但是我無法做到這一點。所以我刪除了G +登錄名。您可以嘗試在應用程序(webView或其他)中執行此操作。只有你有時間。如果你能做到,請告訴我。 – abhi1992

+0

我的問題是,我寫這個:[signIn認證];但我需要這個:[signIn authenticate]; – just