我在iOS 9兼容的应用程序中使用Google Identity Toolkit进行联合登录.我最近更新了所有框架和库,并开始使用
Cocoapods进行依赖关系管理.现在,虽然Facebook登录工作正常,但当用户点击“使用谷歌登录”按钮时,会抛出以下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',reason: 'You must specify |clientID| for |GIDSignIn|'
我设置clientID的AppDelegate中的配置代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { GITClient *gitkitClient = [GITClient sharedInstance]; gitkitClient.apiKey = GITKIT_API_KEY; gitkitClient.widgetURL = GITKIT_WIDGET_URL; gitkitClient.providers = GITKIT_PROVIDERS; [GPPSignIn sharedInstance].clientID = GOOGLE_CLIENT_ID; ...varIoUs unrelated code... }
任何指导都将得到真诚的感谢.
解决方法
如
https://developers.google.com/identity/toolkit/ios/quickstart#step_3_set_up_the_quick-start_app所述,[GIDSignIn sharedInstance] .clientID需要初始化:
GITClient *gitkitClient = [GITClient sharedInstance]; gitkitClient.apiKey = GITKIT_API_KEY; gitkitClient.widgetURL = GITKIT_WIDGET_URL; gitkitClient.providers = @[ kGITProviderGoogle ]; [GIDSignIn sharedInstance].clientID = GOOGLE_CLIENT_ID;