我正在开发iOS应用程序,应该使用我们网站上的API . 为了连接到它,用户应该从设备登录到他的谷歌帐户,然后我们自动连接到API . 我们使用https://developers.google.com/identity/sign-in/ios/start-integrating进行授权
问题是,有多个网站,每个网站都有不同的客户端ID .
我试图更改以编程方式存储CLIENT_ID的.plist,它不起作用:
@IBAction func signInButtonClicked(sender: AnyObject) {
let signInPlistDirectory = *pathToGoogleService-Info.plist*
let signInPlist = NSMutableDictionary(contentsOfFile: signInPlistDirectory)!
if ((webNodeUrl.text?.hasSuffix(".testing-sites.internal")) != nil) {
signInPlist["CLIENT_ID"] = signInPlist["TESTING_CLIENT_ID"]
} else {
signInPlist["CLIENT_ID"] = signInPlist["PROD_CLIENT_ID"]
}
signInPlist.writeToFile(signInPlistDirectory, atomically: true)
}
也许有人知道,甚至有可能吗?
1 回答
文档说明如下:
如果您没有使用其他服务,那么您应该能够在不必费心的情况下离开(不是我确定您在问题中使用示例做了什么) .
在提交登录表单之前,您可以尝试以下内容:
我没有尝试在同一运行时间段内将
clientId
值设置为多个客户端标识符,并且它是一个非常独特的用例,但它值得一试 .还要记住,您在构建时 must 将所有URL方案添加到项目中,没有其他方法 .
根据您的问题,您说您想要使用多个不同的网站(具有不同的客户端ID),但在代码示例中,您似乎只想在不同的开发环境(prod和测试)之间切换 . 如果是这种情况,那么我建议你看一下this answer . 它提供了一些有关管理多个环境的有用提示 .