2015-05-26 77 views
0

我想通过Gmail登录我的应用程序。我使用这段代码,他们为我打开gmail。他们显示屏幕后,不要重定向我的应用程序。请帮助我在iOS中更新。在此屏幕上有代码,并写入复制这些代码,切换到我们的应用程序,并粘贴here.Or是有Gmail登录任何简单的方法,而不是最后一行的Gmail登录iOS

static NSString *const kKeychainItemName = @"OAuth2 Sample: Google+"; 

NSString *kMyClientID = @"7-s.apps.googleusercontent.com";  // pre-assigned by service 
NSString *kMyClientSecret = @"qD-L"; // pre-assigned by service 

NSString *scope = @"https://www.googleapis.com/auth/plus.me"; // scope for Google+ API 

GTMOAuth2ViewControllerTouch *viewController; 


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

[self presentViewController:viewController animated:YES completion:nil]; 

回答

0

[self presentViewController:viewController animated:YES completion:nil];

应该有比如你的下一个屏幕视图控制器的情况下,下一个画面是homeViewController则:

[self presentViewController:homeViewController animated:YES completion:nil];

0

首先使用GooglePlus.framework进行身份验证。它相当容易。 Read more details for Integration

您缺少callback这需要您的应用程序中的以下设置来处理。

Step 1 添加下面的方法你AppDelegate.m文件

- (BOOL)application:(UIApplication *)application 
     openURL:(NSURL *)url 
     sourceApplication:(NSString *)sourceApplication 
     annotation:(id)annotation 
{ 
    //Handle callback here write a code 
} 

Step 2设置你的callback网址在info.plist参考有关详细信息截图。 enter image description here

成功验证后,它将被重定向到您的应用程序。