I have implemented the Google Sign In exactly as Google states to according to their website. I had it working about a month ago, now it just does nothing. I tried to redo everything by deleting the cocoapod and following their website to a T but nothing is happening still. It is like none of the delegate methods are being called, and I am unsure why. Any help would be appreciative. Thanks!
import GoogleSignIn
import Google
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//Get Twitter and set Twitter keys for Application
Twitter.sharedInstance().startWithConsumerKey("uBedaxDuMDgImGbjun1oYf0ay", consumerSecret: "OaKqBZUesX5CypHCwrTvTZE22jrXIuRsUeZzVaMHej11R5Vh3b")
Fabric.with([Twitter.self])
// Initialize sign-in GOOGLE
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: (configureError)")
GIDSignIn.sharedInstance().delegate = self
return true
}
func application(application: UIApplication,
openURL url: NSURL, options: [String: AnyObject]) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url,
sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String,
annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}
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)
}
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
withError error: NSError!) {
print("SIGNING IN")
if (error == nil) {
let email = user.profile.email
print(user.authentication)
// ...
} else {
print("ERROR = (error.localizedDescription)")
}
}
View Controller
import GoogleSignIn
class LoginViewController: UIViewController, UITextFieldDelegate, CLLocationManagerDelegate, GIDSignInUIDelegate
override func viewDidLoad() {
//Default setup for View Controller
super.viewDidLoad()
GIDSignIn.sharedInstance().uiDelegate = self
var error:NSError?
GGLContext.sharedInstance().configureWithError(&error)
if(error != nil) {
print(error)
}
var signInButton = GIDSignInButton(frame: CGRect(x: 0, y: 0, width: 150, height: 400))
view.addSubview(signInButton)
}
EDIT
After HOURS, lol, of figuring this out, the Google Sign-In Button works when it is
1)Held down for more than 2 seconds,
2)Swiped left/down/right but not up
I am unsure of this cause and would be open to suggestions! Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…