谷歌登录的正确iOS代码是什么
我最近将我的GoogleSignin pod从3.x升级到4.1.1,并从这里链接文档: 请点击此处: 它们已经过时了谷歌登录的正确iOS代码是什么,ios,objective-c,google-signin,Ios,Objective C,Google Signin,我最近将我的GoogleSignin pod从3.x升级到4.1.1,并从这里链接文档: 请点击此处: 它们已经过时了 他们说进口是: #导入 它们有一些设置代码: NSError* configureError; [[GGLContext sharedInstance] configureWithError: &configureError]; NSAssert(!configureError, @"Error configuring Google services: %@", c
#导入
NSError* configureError;
[[GGLContext sharedInstance] configureWithError: &configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
(我的意思是,这个问题主要是为了让Google Identity更新文档。我知道答案,我将在下面发布)幸运的是,github示例repo得到了维护。根据这项承诺: 正确的导入是:
#导入
(如果需要,也可以使用@import googlesign
)
上下文
似乎已被删除,因此应删除使用它的代码。似乎没有其他类似的东西需要取代它
有了这两个变化,谷歌登录为我工作。下面是Pod文件的代码
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.2'
use_frameworks!
target ’App Target’ do
pod 'GoogleSignIn'
end
然后在AppDelegate.swift文件中添加标题导入GoogleSignIn
然后func应用程序(application:UIApplication,didFinishLaunchingWithOptions launchOptions:[uiApplicationLaunchOptions:Any]?)->Bool{GIDSignIn.sharedInstance().clientID=“googlesigninclient id”;
}
现在在ViewController类中
class LoginViewController:UIViewController
,GIDSignInUIDelegate, GIDSignInDelegate {
//Add Button action for gmail login
@IBAction func loginWithGmail(_ sender: Any) {
GIDSignIn.sharedInstance().signIn()
}
//deleage method will call after gmail login
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if (error == nil) {//login success
} else {
//login fail
}
}
}
class LoginViewController:UIViewController
,GIDSignInUIDelegate, GIDSignInDelegate {
//Add Button action for gmail login
@IBAction func loginWithGmail(_ sender: Any) {
GIDSignIn.sharedInstance().signIn()
}
//deleage method will call after gmail login
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if (error == nil) {//login success
} else {
//login fail
}
}
}