在使用GIDSignIn处理使用其他Google应用程序登录时,不会获取Google用户

Rid*_*ney 8 iphone ios appdelegate ios8 google-signin

我正在使用谷歌登录iOS和使用模拟器它工作正常,因为没有安装谷歌应用程序和用户获取,但使用我的iPhone 6设备打开youtube(其中有一些注册帐户)的句柄登录.之后,当回到应用程序代码时,请不要输入此功能:

-(void)signIn:(GIDSignIn *) signIn 
    didSignInForUser:(GIDGoogleUser *)
    user withError:(NSError *) error
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我,我不能使用其他功能登录我必须打电话[[GIDSignIn sharedIstance] signIn],此功能检测是否安装了另一个谷歌应用程序,并自动打开另一个谷歌应用程序或Webview.

Aya*_*bar 1

import UIKit
import GoogleSignIn
import Google

class ViewController: UIViewController,GIDSignInUIDelegate, GIDSignInDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    let gidSingIn = GIDSignIn()

    GIDSignIn.sharedInstance().uiDelegate = self
        gidSingIn.delegate = self
    GIDSignIn.sharedInstance().delegate = self

    var configureError:NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)

    assert(configureError == nil, "Error configuring Google services: \(configureError)")


    let button = GIDSignInButton(frame:CGRectMake(0,0,30, 200))
        button.center = self.view.center
        button.backgroundColor = UIColor.blueColor()
       self.view.addSubview(button)



    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func signInGoogle(sender: AnyObject) {

    print("pressed")

}

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        print(user.userID)                // For client-side use only!
        print(user.authentication.idToken) // Safe to send to the server
        print(user.profile.name)
        print(user.profile.givenName)
        print(user.profile.familyName)
        print(user.profile.email)
        print(user.authentication.accessToken)
        print(user.profile)
    } else {
        print("\(error.localizedDescription)")
    }
}
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!,
            withError error: NSError!) {
}
Run Code Online (Sandbox Code Playgroud)

} // 这是使用 Gmail 帐户登录,而不是使用 googleplus。只需在控制器中复制并粘贴即可。并在您的 AppDelegate 类中添加以下函数

func application(application: UIApplication,
                 openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    var options: [String: AnyObject] = [UIApplicationOpenURLOptionsSourceApplicationKey: sourceApplication!,UIApplicationOpenURLOptionsAnnotationKey: annotation]
    return GIDSignIn.sharedInstance().handleURL(url,
                                                sourceApplication: sourceApplication,
                                                annotation: annotation)
}
Run Code Online (Sandbox Code Playgroud)