1

I am using following method two times for login and sign up. So some times I am getting crash. Here is my code:

- (void)signIn:(NSDictionary *)params {
    [[PCUtilities sharedUtilities] showActivityControllerWithMessage:nil inController:self];

    [[PCWebServiceManager sharedWebServiceManager] signInWithParameters:params completionHandler:^(id responseObject, NSError *error) {
        self.signInBtn.enabled = YES;
//        [[PCUtilities sharedUtilities] hideActivityIndicator];

        if (error) {
            [self forceLogout];

            [PCUtilities showAlertWithTitle:nil message:error.localizedDescription cancelButtonTitle:@"OK"];
            [[PCUtilities sharedUtilities] hideActivityIndicator];

        }else {
            PCLoginObject *loginObject = (PCLoginObject *)responseObject;
            [self dismissViewControllerAnimated:NO completion:^{
                [self performSelector:@selector(handleSignInResponse:) withObject:loginObject afterDelay:0.2];
            }];
        }
    }];

}

In above code I am using this method as two time in two different classes, so if possible can any one help me to change the below line from dismissviewcontroller to presentViewcontroller

[self dismissViewControllerAnimated:NO
                         completion:^{
                             [self performSelector:@selector(handleSignInResponse:)
                                        withObject:loginObject
                                        afterDelay:0.2];
                         }];

I am using above method two times. So according to crash report I need to change any one method to present view controller. I have tried but no success.

rptwsthi
  • 10,094
  • 10
  • 68
  • 109
user5513630
  • 1,709
  • 8
  • 24
  • 48
  • Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'When |allowsSignInWithWebView| is enabled, uiDelegate must either be a |UIViewController| or implement the |signIn:presentViewController:| and |signIn:dismissViewController:| methods from |GIDSignInUIDelegate|.' this is that ereo – user5513630 Jan 17 '16 at 11:38
  • 1
    Why isn't that information in the question? – Avi Jan 17 '16 at 11:41

2 Answers2

1

Try adding this method ,this helped me in my case,when I got this warning

//pragma mark - Google SignIn Delegate

- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error {

}

// Present a view that prompts the user to sign in with Google

- (void)signIn:(GIDSignIn *)signIn presentViewController:(UIViewController *)viewController
{
    [self presentViewController:viewController animated:YES completion:nil];
}

// Dismiss the "Sign in with Google" view

- (void)signIn:(GIDSignIn *)signIn dismissViewController:(UIViewController *)viewController {
    [self dismissViewControllerAnimated:YES completion:nil];

}

//completed sign In

- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
//user signed in
//get user data in "user" (GIDGoogleUser object)
}
Rohit Pradhan
  • 3,867
  • 1
  • 21
  • 29
  • actually your last code //completed sign delegate i am having already. And in my above code i posted one of that method will call after the `google plus` delegate. inside that method also i am having some method will call..So in order to call the another method how will i use the present and dismiss view controller – user5513630 Jan 17 '16 at 13:03
  • see my dismiss VC code inside that i am calling`handlesigninresponse` so how to add that method in your presentVC code?/ – user5513630 Jan 17 '16 at 13:05
  • The above code is for Google signIn,,Have you used custom button or used the button given by SDK – Rohit Pradhan Jan 17 '16 at 13:13
  • i used custom button.. if so i will upload the full code how i use that google plus for both sign in and sign up – user5513630 Jan 17 '16 at 13:39
  • http://stackoverflow.com/questions/34368613/custom-google-sign-in-button-ios/34368678#34368678 please refer my answer it will help you – Rohit Pradhan Jan 17 '16 at 13:42
  • and use google sign In instead of G+ ..Because G+ is deprecated they suggest to use google signIn – Rohit Pradhan Jan 17 '16 at 13:44
0

Try to set

[GIDSignIn sharedInstance].delegate = self;

in your viewDidAppear method,not in viewDidLoad

metronic
  • 455
  • 5
  • 15