1

我们可以在不将 UIViewcontroller 设置为委托的情况下使用 Google 登录吗?我在 GooglePlus API 中做过同样的事情,现在似乎不起作用,抛出异常..

*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“uiDelegate 必须是 |UIViewController| 或实现 |signIn:presentViewController:| 和 |signIn:dismissViewController:| 来自 |GIDSignInUIDelegate| 的方法。'

由于许多屏幕依赖于谷歌登录,而不是在任何地方添加登录代码,我创建了谷歌管理器单例类并抽象了所有登录逻辑。一旦使用访问令牌登录成功,此类将提供回调。当我使用 Google Plus API 时,我正在设置这样的委托......

signIn = [GPPSignIn sharedInstance];
        signIn.shouldFetchGoogleUserEmail = YES; // adds scope for "https://www.googleapis.com/auth/userinfo.email"
        signIn.shouldFetchGooglePlusUser = YES; // adds scope for "https://www.googleapis.com/auth/plus.me"
        signIn.clientID = kClientId;
        signIn.scopes = @[@"https://www.googleapis.com/auth/plus.login", @"profile", @"https://www.googleapis.com/auth/user.birthday.read"];
        signIn.delegate = self;
        signIn.attemptSSO = true;

它按预期工作,现在我已经迁移到谷歌登录,因为谷歌加号已被弃用,

gSignIn = [GIDSignIn sharedInstance];
gSignIn.shouldFetchBasicProfile = YES;
gSignIn.clientID = kClientId;
gSignIn.scopes = @[ @"profile", @"email" ];
gSignIn.delegate = self;
gSignIn.uiDelegate = self;
[gSignIn signIn];

它不允许我将单例类设置为委托,在运行时它会抛出异常。

是否可以在 Google 登录中将 NSObject 类设置为委托?或者有什么解决方法吗?

4

0 回答 0