@class GPPSignInButton;
我不想使用 GPPSignInButton
进行登录和身份验证,我想在按下时使用我的自定义按钮,然后登录过程将开始,并像 facebook 一样使用强制 webview 登录也可以在 Google+ 中登录吗?
就像“Using the OAuth 2 Controllers”
提前致谢
任何帮助将不胜感激。
最佳答案
是的,您可以使用任何 UIButton,而不是使用 GPPSignInButton。
使用以下方法在 viewDidLoad 中初始化 Google+ sdk:
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to not get the user's email
signIn.clientID = kClientId;
signIn.scopes = [NSArray arrayWithObjects:kGTLAuthScopePlusMe,kGTLAuthScopePlusLogin, nil];
signIn.delegate = self;
现在在 uibutton 操作中
- (IBAction)googlePlusSignIn:(id)sender
{
GPPSignIn *signIn = [GPPSignIn sharedInstance];
if([[GPPSignIn sharedInstance] authentication])
{
[signIn trySilentAuthentication];
}
else
{
// This is method that opens the G+ sign view
[signIn authenticate];
}
}
在 Targets -> Info -> URL Types 中添加 URL 类型和 URL 方案。
然后在App Delegate中添加以下内容
- (BOOL)application: (UIApplication *)application
openURL: (NSURL *)url
sourceApplication: (NSString *)sourceApplication
annotation: (id)annotation {
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
关于ios - 谷歌使用google sdk登录ios?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30906435/