i am using google sdk for google signin but after entering the email and password
in viewDidLoad i have added delegate
//set Google sign In delegates
[GIDSignIn sharedInstance].delegate = self;
[GIDSignIn sharedInstance].uiDelegate = self;
-(void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error{
}
not called . where is the issue not getting
when i am entering user email and password i am getting this
this method is called and showing error is null.
- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error {
}
Add following code in your AppDelegate.m file
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
return [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
The method that get's called is called on GIDSignInUiDelegate
, while the method that is not called is called on the GIDSignInDelegate
after login. Here's what the GIDSignIn header file says:
@protocol GIDSignInDelegate <NSObject>
- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error;
@protocol GIDSignInUIDelegate <NSObject>
@optional
- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error;
Since you have set both the uiDelegate and the delegate to your UIViewController instance, both methods should get called.
When I encountered the same problem, my mistake was, that I also set the AppDelegate to be the GIDSignInDelegate
causing confusion for hours! So my advice: double check if your ViewController still is the delegate
of GIDSignIn.sharedInstance
when returning from sign in. E.g. set a breakpoint in the callback that get's called:
- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error {
if (GIDSignIn.delegate != self) {NSLog("gotcha!")}
}
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