2016-06-08 55 views
2

我在我的應用程序中實現了google signInGIDSignInDelegate方法不在iOS中調用8.4

它在iOS 9+工作正常。但它在8+版本中造成問題。

我已經初始化,谷歌在爲登陸:

[GIDSignIn sharedInstance].uiDelegate = self; 
    [GIDSignIn sharedInstance].delegate = self; 

在我button點擊下面的代碼是他們的:

- (void)userDidTapSignInButton:(UIButton*)sender { 

     [[GIDSignIn sharedInstance] signIn]; 

    } 

只有這Google Delegate被稱爲:

- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error { 

     NSLog(@"Show Sign In Screen"); 

    } 

後此頁面中的Google Sign打開。當我按下確認和完成後輸入我的用戶登錄詳情後,我被重定向回我的應用程序。此後沒有任何反應。

既不成功也不失敗委託被調用。

- (void)signIn:(GIDSignIn *)signIn 
      didSignInForUser:(GIDGoogleUser *)user 
withError:(NSError *)error { 
     NSLog(@"Google Sign IN SUccess"); 
    } 

故障代表:

- (void)signIn:(GIDSignIn *)signIn 
    didDisconnectWithUser:(GIDGoogleUser *)user 
withError:(NSError *)error { 
    NSLog(@"google sign in fail with error"); 
    } 

當我的iOS 9.2或9.3上運行我的應用效果很好每位代表被調用。但不是在iOS 8.4,8.3,...

我無法弄清楚它背後的原因。

此外,我沒有得到控制檯中的任何日誌或錯誤消息。

回答

1

你必須實現開放url函數的ios 9.0版本和ios 8.0版本。

@available(iOS 8.0,*) 
func application(application: UIApplication, 
       openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
    print("sign in with annotation") 
    return GIDSignIn.sharedInstance().handleURL(url, 
               sourceApplication: sourceApplication, 
               annotation: annotation) 
} 
@available(iOS 9.0, *) 
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { 
    print("sign in with options") 
    return GIDSignIn.sharedInstance().handleURL(url, 
               sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String?, 
               annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) 
} 
+0

嗨,歡迎來到堆棧溢出。發佈答案時,請儘量提供更多信息:解釋您發現的錯誤和您發佈的解決方案:另請參閱如何回答:http://stackoverflow.com/help/how-to-answer –

+0

Hello RahulMishra,有你通過可可豆莢或iOS sdk完成了谷歌登錄集成嗎? – puja

+0

@puja是的,我已經完成了。你仍然面臨問題嗎? – Dalvik

相關問題