Ridney Ridney - 3 years ago 127
iOS Question

Not fetch Google user when handle sign in with another Google app using GIDSignIn

I'm using Google Sign-In for iOS and when using simulator it's working fine because no google app is installed and user is fetch, but when using my iPhone 6 device open youtube (with some registered account inside them) for handle sign in.
After, when come back on the app code don't enter on this function :

-(void)signIn:(GIDSignIn *) signIn
didSignInForUser:(GIDGoogleUser *)
user withError:(NSError *) error

Anyone can help me i can't use another function for login i must call
[[GIDSignIn sharedIstance] signIn]
and this function detect if another google app is installed and automatically open another google app or Webview.

Answer Source
import UIKit
import GoogleSignIn
import Google

class ViewController: UIViewController,GIDSignInUIDelegate, GIDSignInDelegate {

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

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

    var configureError:NSError?

    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()

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

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

@IBAction func signInGoogle(sender: AnyObject) {



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
    } else {
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!,
            withError error: NSError!) {

} // this is login with gmail account not for googleplus. just copy and past within your controller. and add following func in your AppDelegate Class

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download