Firebase Google 登录不起作用/Swift

问题描述

我像 YouTube 上的教程一样集成了所有内容,但它不起作用。当我点击按钮时,它什么也不做... 我导入了所有模块并安装了所有 pod。 有人能帮我吗? 教程链接https://www.youtube.com/watch?v=20Qlho0G3YQ

视图控制器

let googleLoginButton = GIDSignInButton()

override func viewDidLoad() {
        super.viewDidLoad()
        
        GIDSignIn.sharedInstance()?.presentingViewController = self
        
        ...

}

func configureStackView() {
        loginView.addSubview(StackView)
        StackView.alignment = .center
        StackView.distribution = .equalSpacing
        StackView.axis = .horizontal
        StackView.backgroundColor = .white
        StackView.spacing = 5
        
        //Adding Elements
        StackView.addArrangedSubview(googleLoginButton)
        StackView.addArrangedSubview(facebookLoginButton)
        StackView.addArrangedSubview(appleLoginButton)
        
        
        //Constraints
        StackView.translatesAutoresizingMaskIntoConstraints = false
        StackView.centerXAnchor.constraint(equalTo: loginView.centerXAnchor).isActive = true
        StackView.bottomAnchor.constraint(equalTo: loginView.bottomAnchor,constant: -10).isActive = true
        StackView.heightAnchor.constraint(equalToConstant: 100).isActive = true
        StackView.leadingAnchor.constraint(equalTo: loginView.leadingAnchor,constant: 35).isActive = true
        StackView.trailingAnchor.constraint(equalTo: loginView.trailingAnchor,constant: -35).isActive = true
    
        //MARK: - Configure Login Buttons
        
    //Configure GoogleButton
//        googleLoginButton.setimage(googlelogo,for: .normal)
        googleLoginButton.layer.cornerRadius = 25
//        googleLoginButton.imageView?.contentMode = .scaleAspectFit
       
        
        //Constraints
        googleLoginButton.translatesAutoresizingMaskIntoConstraints = false
        googleLoginButton.widthAnchor.constraint(equalToConstant: 45).isActive = true
        googleLoginButton.heightAnchor.constraint(equalToConstant: 45).isActive = true

   
...

应用委托

import UIKit
import CoreData
import Firebase
import GoogleSignIn

@main
class AppDelegate: UIResponder,UIApplicationDelegate,GIDSignInDelegate {

var window: UIWindow?

    func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
       
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()
        
        
        
        let mainController = LoginVCViewController()
        window?.rootViewController = mainController
        
        FirebaseApp.configure()
        GIDSignIn.sharedInstance()?.clientID = "7029977741-p82g70k9kfqqkljp08edb4q5jilp4le3.apps.googleusercontent.com"
        GIDSignIn.sharedInstance()?.delegate = self
        return true
    }
    
    func sign(_ signIn: GIDSignIn!,didSignInFor user: GIDGoogleUser!,withError error: Error!) {
        print("User: \(user.profile.email ?? "No Email")")
    }
    
    func application(_ app: UIApplication,open url: URL,options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return ((GIDSignIn.sharedInstance()?.handle(url)) != nil)
    }

提前致谢

第二个问题:如何自定义只有 G 可见的 Button 及其圆形?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)