Search code examples
iphoneobjective-ciosuiviewgdata

Redirect Back from uiweb view in gdata integration


I am making an application to integrate gmail to my app. I am able to login to gmail by gadata-objective c-client-1.11.0.a. I am giving the code

-(IBAction)googlelogin
{
    NSString *scope = @"https://www.googleapis.com/auth/plus.me"; // scope for Google+ API

    GTMOAuth2ViewControllerTouch *viewController = [[[GTMOAuth2ViewControllerTouch alloc] initWithScope:scope clientID:kMyClientID clientSecret:kMyClientSecret keychainItemName:nil delegate:self finishedSelector:@selector(viewController:finishedWithAuth:error:)] autorelease];

    NSString *html = @"<html><body><div align=center>Loading sign-in page...</div></body></html>";
   [viewController setInitialHTMLString:html];

   [self presentModalViewController:viewController animated:NO];        

}

now i want to redirect back to my app after google login to get the contacts of gmail. Help me how to generate taken and return back to my app after login

thanks


Solution

  • you should implement the method

    - (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
      finishedWithAuth:(GTMOAuth2Authentication *)auth
                 error:(NSError *)error {
     if (error != nil) {
      // Authentication failed
     }   else {
         // Authentication succeeded
       // here you should push your the root view controller of your app.
     }
    

    }