Google登录按钮无效 [英] Google Sign In Button does Nothing

查看:156
本文介绍了Google登录按钮无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照其网站的说法完全按照谷歌的说法实施了Google登录。我有一个月前的工作,现在它什么也没做。我试图通过删除cocoapod并将他们的网站发送到T来重做所有内容,但仍然没有发生任何事情。就像没有调用任何委托方法一样,我不确定为什么。任何帮助都会很有意义。谢谢!

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

查看控制器

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)

}  

编辑

在HOURS之后,哈哈搞清楚这一点,谷歌登录按钮工作时,它是
1)持续超过2秒,
2)向左/向右/向右滑动但不向上
我我不确定这个原因,并愿意接受建议!谢谢!

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!

推荐答案

我已经想通了,想让其他人知道这个愚蠢的愚蠢问题!

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

问题在于Google按钮和点击我必须关闭键盘。
我没有把它放在这里,但现在是。

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!

这篇关于Google登录按钮无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆