I'm introducing Google Sign-In to my app and whilst both Google and Firebase documentation is thorough enough, what I have done as they suggested is not sufficient... I am still getting this error. Hopefully this will help others with finding a solution to the problem when implementing their SDK....thanks in advance for reviewing this chunky one:
Here's the Firebase guide and the Google guide:
So
App Delegate has the following, with no errors but I notice there are likely to be conflicts between Facebook login (working correctly) and newly Google, which I've no idea how to handle together:
P.S. I have NOT added GIDSignInDelegate to AppDelegate here because I am planning for my VC to handle the login logic, as you will see below...
LoginVC ViewController code here:
class LoginVC: UIViewController, UIViewControllerTransitioningDelegate, UITextViewDelegate, UITextFieldDelegate, GIDSignInDelegate, GIDSignInUIDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let ref = Firebase(url: "https://MYAPPID.firebaseio.com")
GIDDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().signInSilently() // for if the user has recently been authenticated
}
Then this, which from what I can see... should be everything Google needs to talk to Firebase:
// Implementing the required GIDSignInDelegate methods
func googleSignIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
if (error == nil) {
// Auth with Firebase
let userId = user.userID
let idToken = user.authentication.idToken
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
ref.authWithOAuthProvider("google", token: user.authentication.accessToken, withCompletionBlock: { (error, authData) in
// User is logged in!
})
} else {
print("\(error.localizedDescription)")
}
}
func googleSignOut() {
GIDSignIn.sharedInstance().signOut()
ref.unauth()
}
// Implement the required GIDSignInDelegate methods and Unauth when disconnected from Google
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!, withError error: NSError!) {
ref.unauth()
}
// IBAction to handle the sign-in process
@IBAction func googleButtonPressed(sender: TKTransitionSubmitButton!) {
GIDSignIn.sharedInstance().signIn()
}
Baffled? Sorry for the long one guys...but I've done everything the Firebase guide suggests and that means the logic in the Google doc for AppDelegate is all there in the ProfileVC. Any pointers?
It's saying your class have not implemented required method for your GIDSignInDelegate
. There are major change in name of method in Swift 3. So your new method will be
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: NSError!)
Please check Library screen shot. So In
is missing in new swift 3 convention of naming of methods or classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With