我正在使用
Google Sign-In for iOS,当使用模拟器它工作正常,因为没有安装谷歌应用程序和用户获取,但当使用我的iPhone 6设备打开youtube(其中有一些注册帐户)的句柄登录.
之后,当回到应用程序代码时,请不要输入此功能:
之后,当回到应用程序代码时,请不要输入此功能:
-(void)signIn:(GIDSignIn *) signIn didSignInForUser:(GIDGoogleUser *) user withError:(NSError *) error
任何人都可以帮助我我不能使用其他功能登录我必须调用[[GIDSignIn sharedIstance] signIn]并且此功能检测是否安装了另一个谷歌应用程序并自动打开另一个谷歌应用程序或Webview.
解决方法
import UIKit import GoogleSignIn import Google class ViewController: UIViewController,GIDSignInUIDelegate,GIDSignInDelegate { override func viewDidLoad() { super.viewDidLoad() let gidSingIn = GIDSignIn() GIDSignIn.sharedInstance().uiDelegate = self gidSingIn.delegate = self GIDSignIn.sharedInstance().delegate = self var configureError:NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil,"Error configuring Google services: \(configureError)") let button = GIDSignInButton(frame:CGRectMake(0,30,200)) button.center = self.view.center button.backgroundColor = UIColor.blueColor() self.view.addSubview(button) // Do any additional setup after loading the view,typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func signInGoogle(sender: AnyObject) { print("pressed") } func signIn(signIn: GIDSignIn!,didSignInForUser user: GIDGoogleUser!,withError error: NSError!) { if (error == nil) { // Perform any operations on signed in user here. print(user.userID) // For client-side use only! print(user.authentication.idToken) // Safe to send to the server print(user.profile.name) print(user.profile.givenName) print(user.profile.familyName) print(user.profile.email) print(user.authentication.accessToken) print(user.profile) } else { print("\(error.localizedDescription)") } } func signIn(signIn: GIDSignIn!,didDisconnectWithUser user:GIDGoogleUser!,withError error: NSError!) { }
}
//这是使用gmail帐户登录而不是googleplus.只需在您的控制器中复制和过去.
并在AppDelegate类中添加以下func
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) }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。