Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 911
impression7vx Avatar asked Jun 10 '16 07:06

impression7vx


People also ask

Why when I click sign in on Google nothing happens?

This issue can be caused by corrupted cookies or cookies that are blocked. Clear the Cache and remove the Cookies from websites that cause problems via the "3-bar" Firefox menu button (Options/Preferences). I was having the same issue, except that even in a private windows it wasnt working.

Why is sign in with Google Not Working?

Your sign-in may be blocked if the device or location you're using is new. Try again from a device or location that you commonly sign in from. Sign in to your Google Account on the new device and try again the following week.

Why can't I sign in with Google on Chrome?

Refresh, Update, or Reinstall Google Chrome. If you know your username and password, but you can't sign in to your Google Account, you can refresh the Google Chrome browser and try to log in again. You can also update Chrome to the latest version or reinstall Chrome browser to have a try again.

Where is the sign in button on Chrome?

Click the icon in the upper, right-hand corner of Chrome that looks like a person. 3. Click the “Sign in to Chrome” button. 4.


2 Answers

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
like image 143
almost_anonymous Avatar answered Oct 07 '22 19:10

almost_anonymous


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!

like image 23
impression7vx Avatar answered Oct 07 '22 19:10

impression7vx