swift - GIDSignIn.sharedInstance : sharedInstance not a function?

标签 swift google-signin

在此代码中,当我键入 GIDSignIn.sharedInstance 时,出于某种原因 sharedInstance 不是函数,这意味着我无法访问 clientID。我在任何地方都找不到解决方案。

import UIKit
import GoogleSignIn


@main

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
GIDSignIn.sharedInstance().clientID = "clientID"
        
          return true
    }

最佳答案

在最新版本的 GoogleSignIn SDK 中。删除了此方法。

现在在新版本中点击此链接或下方代码。 https://developers.google.com/identity/sign-in/ios/sign-in

@IBAction func clkLoginWithGmail(_ sender: UIButton) {
     let signInConfig = GIDConfiguration.init(clientID: "clientID-XYZ")
     GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in

     }
}

关于swift - GIDSignIn.sharedInstance : sharedInstance not a function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68950569/

相关文章:

ios - SpriteKit 滚动 SKCameraNode 非常有问题

php - 尝试运行任务、发送图像时,出现错误 Code=13 "query cancelled"

firebase - Firebase for Flutter 中此身份验证背后的逻辑是什么?

react-native - 如何在没有 Firebase 的情况下为 React Native App 设置 Google 登录?

android - 在android应用程序中集成outlook 365登录

json - 如何在 swift 3.0 中通过 url 使用异步方式获取多个 JSON 数据

Swift - 使用 CGSize 执行选择器

ios - 使用 Swift 3 解析 JSON

ios - Google 登录 iOS SDK 中出现可能可恢复的错误

android - Firebase google SignIn 结果总是错误的?