2015-09-07 19 views
13

我手動集成了谷歌登錄sdk(而不是cocoapods)並且它構建成功,但是當我運行項目I總是在登錄後出現此錯誤:「使用GIDSignIn登錄時沒有URL方案com-google-gidconsent的註冊處理程序」錯誤

2015-09-07 15:44:14.071 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent-google 
2015-09-07 15:44:14.071 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent-youtube 
2015-09-07 15:44:14.072 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent 
2015-09-07 15:44:14.072 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com.google.gppconsent.2.4.1 
2015-09-07 15:44:14.072 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com.google.gppconsent.2.4.0 

這就是我如何使用sdk。

首先我按照從https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift的所有步驟。

代碼:
AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
    // google 
    // Initialize sign in 
    GIDSignIn.sharedInstance().clientID = "<client id>" 
    GIDSignIn.sharedInstance().delegate = self 

    return true 
} 

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) { 

    if error == nil { 
     let userID = user.userID 
     let idToken = user.authentication.idToken 
     let name = user.profile.name 
     let email = user.profile.email 

     print(userID, idToken, name, email) 
    } else { 
     print(error.localizedDescription) 
    } 
} 

func signIn(signIn: GIDSignIn!, didDisconnectWithUser user: GIDGoogleUser!, withError error: NSError!) { 

} 

ViewController.swift

override func viewDidLoad() { 
     super.viewDidLoad() 

     // google plus 
     //GIDSignIn.sharedInstance().clientID = clientID 
     GIDSignIn.sharedInstance().uiDelegate = self 
     GIDSignIn.sharedInstance().signIn() 
} 

什麼可以是問題?我正在使用SDK 2.2.0版本

回答

29

您的實施沒有問題。所有這些警告意味着每個URL方案引用的應用程序未安裝在設備上。

如果您在模擬器上進行測試,您將一直得到這些錯誤。但是,如果您在設備上進行測試,則可以驗證如果安裝了相應的應用程序,錯誤將會消失。

舉例來說,如果你有你的設備上訪問YouTube應用,你將看不到該行:

2015-09-07 15:44:14.071 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent-youtube 
-1
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com"]]; 
     exit(0); 
}) 
+2

心靈解釋? – CinCout

+0

請詳細說明如何回答這個問題。 – JAL