How to prevent the extra view displaying an access code when using Google OAuth 2.0

前端 未结 8 994
挽巷
挽巷 2020-12-14 12:18

I followed http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers.html to allow users to use Google to login to an iPhone app. After I tap \"Allow access\" bu

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 12:40

    It turns out this is pretty straightforward. In the login callback, simply dismiss and remove viewController from the parent view controller.

    - (void)viewController:(UIViewController *)viewController
          finishedWithAuth:(GTMOAuth2Authentication *)auth
                     error:(NSError *)error
    {
        if (error == nil) {
            // Get rid of the login view.
            // self.parentViewController was saved somewhere else and is the parent
            // view controller of the view controller that shows the google login view.
            [self.parentViewController dismissViewControllerAnimated:NO completion:nil];
            [viewController removeFromParentViewController];
    
            // Tell the delegate that the user successfully logged in ...
        } else {
            // Error handling code ...
        }
    }
    

提交回复
热议问题