单击Google登录按钮时没有任何反应

时间:2019-05-25 13:00:37

标签: swift firebase google-signin

Update2:断点似乎不起作用,因为没有停止并且输出相同的结果

2019-05-25 21:12:10.264321+0700 dacna[6350:1182456]  - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2019-05-25 21:12:10.359445+0700 dacna[6350:1182465] 5.19.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50800000 started
2019-05-25 21:12:10.359560+0700 dacna[6350:1182465] 5.19.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see [URL][1])
2019-05-25 21:12:10.803643+0700 dacna[6350:1182463] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x7fc4de100950] get output frames failed, state 8196
2019-05-25 21:12:10.804027+0700 dacna[6350:1182463] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x7fc4de100950] get output frames failed, state 8196
2019-05-25 21:12:10.805877+0700 dacna[6350:1182463] TIC Read Status [2:0x0]: 1:57
2019-05-25 21:12:10.805994+0700 dacna[6350:1182463] TIC Read Status [2:0x0]: 1:57
2019-05-25 21:12:11.182929+0700 dacna[6350:1182463] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fc4de108110] get output frames failed, state 8196
2019-05-25 21:12:11.183159+0700 dacna[6350:1182463] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fc4de108110] get output frames failed, state 8196
2019-05-25 21:12:11.183561+0700 dacna[6350:1182463] TIC Read Status [1:0x0]: 1:57
2019-05-25 21:12:11.183658+0700 dacna[6350:1182463] TIC Read Status [1:0x0]: 1:57
2019-05-25 21:12:11.430492+0700 dacna[6350:1182464] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C3.1:2][0x7fc4dbc1aae0] get output frames failed, state 8196
2019-05-25 21:12:11.430687+0700 dacna[6350:1182464] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C3.1:2][0x7fc4dbc1aae0] get output frames failed, state 8196
2019-05-25 21:12:11.431169+0700 dacna[6350:1182464] TIC Read Status [3:0x0]: 1:57
2019-05-25 21:12:11.431315+0700 dacna[6350:1182464] TIC Read Status [3:0x0]: 1:57

Update1:​​忘了提一下,在发生此错误之前,加载视图时,它会自动“执行”“登录”,我不知道那是什么问题按照Firebase中的文档进行操作。

起初,它仍在工作,但是出现错误403“受限制的客户端”。

我遵循this post中的第一个答案,我必须添加电子邮件支持,问题已解决。但是,使用电子邮件登录后,谷歌页面关闭了。

从那时起,当我单击登录按钮时,什么也没发生

AppDelegate

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate{

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        UINavigationBar.appearance().barTintColor = UIColor(red: 200.0/255.0, green: 14.0/255.0, blue: 74.0/255.0, alpha: 1.0)// Use Firebase library to configure APIs
        FirebaseApp.configure()
        GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
        GIDSignIn.sharedInstance().delegate = self
        return true
    }

    func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
        -> Bool {
            return GIDSignIn.sharedInstance().handle(url,
                                                     sourceApplication:options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,annotation: [:])
    }

    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
        // ...
        if let error = error {
            print("Having an error \(error)")
            return
        }
        guard let authentication = user.authentication else { return }
        let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
                                                       accessToken: authentication.accessToken)
    }

ViewController

import Firebase
import GoogleSignIn
class LoginController: UIViewController, GIDSignInUIDelegate, GIDSignInDelegate,UIGestureRecognizerDelegate{
    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
        // ...
        if let error = error {
            print("We have an error \(error)")
            return
        }
        guard let authentication = user.authentication else { return }
        let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
                                                       accessToken: authentication.accessToken)
        Auth.auth().signInAndRetrieveData(with: credential) { (authResult, error) in
            if let error = error {
                // DO IF ERROR HAPPENDS
                print("abc\(error)")
                return
            }
            // User is signed in
            print("success")
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        GIDSignIn.sharedInstance().uiDelegate = self
        GIDSignIn.sharedInstance().signIn()
        // Do any additional setup after loading the view.
    }


}

0 个答案:

没有答案