Google Sign In Button does Nothing

I have implemented the Google Sign In exactly as Google states to according to their website. I had it working about a month ago, now it just does nothing. I tried to redo everything by deleting the cocoapod and following their website to a T but nothing is happening still. It is like none of the delegate methods are being called, and I am unsure why. Any help would be appreciative. Thanks!

import GoogleSignIn
import Google
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    //Get Twitter and set Twitter keys for Application
    Twitter.sharedInstance().startWithConsumerKey("uBedaxDuMDgImGbjun1oYf0ay", consumerSecret: "OaKqBZUesX5CypHCwrTvTZE22jrXIuRsUeZzVaMHej11R5Vh3b")
    Fabric.with([Twitter.self])

    // Initialize sign-in GOOGLE
    var configureError: NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)
    assert(configureError == nil, "Error configuring Google services: \(configureError)")

    GIDSignIn.sharedInstance().delegate = self

    return true
}

func application(application: UIApplication,
                 openURL url: NSURL, options: [String: AnyObject]) -> Bool {
    return GIDSignIn.sharedInstance().handleURL(url,
                                                sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String,
                                                annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}

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

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    print("SIGNING IN")
    if (error == nil) {
        let email = user.profile.email
        print(user.authentication)
        // ...
    } else {
        print("ERROR = \(error.localizedDescription)")
    }
}

View Controller

  • When would CBCentralManager's state ever be powered on but still give me a “not powered on” warning?
  • UIAlertView with textfield and three buttons issue in ios 6
  • NSDictionary Key For Value/Object?
  • How to change PFUser password in Swift?
  • Cut rounded image with the face from CIDetector and CIFaceFeature
  • iPhone: Detecting Tap in MKMapView
  • import GoogleSignIn
    class LoginViewController: UIViewController, UITextFieldDelegate, CLLocationManagerDelegate, GIDSignInUIDelegate
     override func viewDidLoad() {
    
        //Default setup for View Controller
        super.viewDidLoad()
    
        GIDSignIn.sharedInstance().uiDelegate = self
        var error:NSError?
        GGLContext.sharedInstance().configureWithError(&error)
        if(error != nil) {
            print(error)
        }
    
        var signInButton = GIDSignInButton(frame: CGRect(x: 0, y: 0, width: 150, height: 400))
        view.addSubview(signInButton)
    
    }  
    

    EDIT

    After HOURS, lol, of figuring this out, the Google Sign-In Button works when it is
    1)Held down for more than 2 seconds,
    2)Swiped left/down/right but not up
    I am unsure of this cause and would be open to suggestions! Thanks!

    4 Solutions Collect From Internet About “Google Sign In Button does Nothing”

    I have figured it out, would like to let anyone else know this stupid stupid issue!

    The problem is with the Google button and the tap I have to dismiss the keyboard.
    I didn’t put it on here, but here it is.

    let tap = UITapGestureRecognizer(target: self, action: #selector(LoginViewController.dismissKeyboard))
    self.view.addGestureRecognizer(tap)
    
    func dismissKeyboard() {
        self.view.endEditing(true)
    }
    

    Google’s Delegates mess this up for some reason. I haven’t come up with a solution yet, as I literally just now found the issue, but if anyone else has an issue, I hope this helps!

    I had the same issue and that was a problem with a tap gesture recognizer that was bound to the main view in order to dismiss keyboard. It was accidentally capturing also the touches inside the GIDSignInButton. Changing this setting helped:

    tapGesture.cancelsTouchesInView = false
    

    Implement your UITapGestureRecognizer’s delegate and handle the case you tapped on your Google sign in button:

    func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
        if touch.view is GIDSignInButton {
            return false
        }
        return true
    }
    

    That solved the problem for me.

    Quick, Easy Solution:

    Steps:

    1. Extend to UIGestureRecognizerDelegate
    2. Paste in the following methods
    3. add dismissOnTap() to your view controller

    Code:

    class ViewController: UIViewController, UIGestureRecognizerDelegate {
    
     override func viewDidLoad() {
            super.viewDidLoad()
    
            // Call dismissOnTap
            dismissOnTap()
    
     }
    
     func dismissOnTap() {
            self.view.isUserInteractionEnabled = true
            let tap = UITapGestureRecognizer(target: self, action: Selector("dismissKeyboard"))
            tap.delegate = self
            tap.cancelsTouchesInView = false
            self.view.addGestureRecognizer(tap)
     }
    
        func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
            if touch.view is GIDSignInButton {
                return false
            }
            return true
        }
    
        func dismissKeyboard() {
            self.view.endEditing(true)
        }
    
    }