iOS Google 登录视图缺少导航栏和底部栏
iOS Google SignIn view missing navigation bar and bottom bar
@interface GooglePlusManager() <GIDSignInDelegate,GIDSignInUIDelegate>
@property (nonatomic, strong) GIDSignIn *gppSignIn;
@property (nonatomic, weak) UIViewController * localVC;
@end
@implementation TWNGooglePlusManager
(void)doGooglePlusLogin: (UIViewController *)viewController
{
[self setPropertiesToInitialState];
NSString* clientId = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"GoogleClientId"];
self.gppSignIn = [GIDSignIn sharedInstance];
[self.gppSignIn setClientID:clientId];
if (self.gppSignIn)
{
self.gppSignIn.scopes = @[ @"profile", @"email" ];
[self.gppSignIn setDelegate:self];
self.localVC = viewController;
[self.gppSignIn setUiDelegate:self];
self.gppSignIn.allowsSignInWithWebView = YES;
[self.gppSignIn signIn];
}
}
#pragma mark - GIDSignInUiDelegate
(void)signIn:(GIDSignIn *)signIn presentViewController:(UIViewController *)viewController {
[self.localVC presentViewController:viewController animated:YES completion:nil];
}
@end
基本上,GIDSignIn 在我的 GooglePlusManager 中,我将当前 SignIN ViewController 传递给 GooglePlusManager,一切正常,除了登录页面没有 backbutton/cancel 按钮。我已经尝试将 setUiDelegate 设置为 self 或 VC,结果是一样的。
发生在真正的 9.0 设备和 9.1 模拟器中。
找出答案是我错过了 SafariServices.framework。在我将 SafariServices.framework 链接到应用程序后,它可以正常工作。
@interface GooglePlusManager() <GIDSignInDelegate,GIDSignInUIDelegate>
@property (nonatomic, strong) GIDSignIn *gppSignIn;
@property (nonatomic, weak) UIViewController * localVC;
@end
@implementation TWNGooglePlusManager
(void)doGooglePlusLogin: (UIViewController *)viewController
{
[self setPropertiesToInitialState];
NSString* clientId = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"GoogleClientId"];
self.gppSignIn = [GIDSignIn sharedInstance];
[self.gppSignIn setClientID:clientId];
if (self.gppSignIn)
{
self.gppSignIn.scopes = @[ @"profile", @"email" ];
[self.gppSignIn setDelegate:self];
self.localVC = viewController;
[self.gppSignIn setUiDelegate:self];
self.gppSignIn.allowsSignInWithWebView = YES;
[self.gppSignIn signIn];
}
}
#pragma mark - GIDSignInUiDelegate
(void)signIn:(GIDSignIn *)signIn presentViewController:(UIViewController *)viewController {
[self.localVC presentViewController:viewController animated:YES completion:nil];
}
@end
基本上,GIDSignIn 在我的 GooglePlusManager 中,我将当前 SignIN ViewController 传递给 GooglePlusManager,一切正常,除了登录页面没有 backbutton/cancel 按钮。我已经尝试将 setUiDelegate 设置为 self 或 VC,结果是一样的。 发生在真正的 9.0 设备和 9.1 模拟器中。
找出答案是我错过了 SafariServices.framework。在我将 SafariServices.framework 链接到应用程序后,它可以正常工作。