首页 > 解决方案 > 如何将 Google 登录与 Realm iOS SDK 集成

问题描述

在遵循https://docs.mongodb.com/realm/ios/quick-start/上的步骤后,我已经构建了我的大部分应用程序,之前指示我们使用 cocoa-pod RealmSwift 版本 10.0.0-beta.2

我试图在这里实现示例代码https://docs.mongodb.com/realm/ios/authenticate/#ios-login-google 并注意到许多函数和类名不同(不确定它是否引用 5.3. 6)。

我正在研究 Github 上的 repo 并注意到 10.0.0-beta.4 具有用于集成“使用 Apple 登录”的新代码和示例,因此 RealmSwift 可能并不完全支持 Mongo 中支持的所有身份验证方法阿特拉斯

我的登录快速入门教程中的代码是

app.login(withCredential: AppCredentials(username: username!, password: password!)) { [weak self](user, error) in

当然运行良好,但是下面的代码

let gToken = GIDSignIn.sharedInstance()?.currentUser.authentication.idToken
app.login(withCredential: AppCredentials.init(googleToken: gToken!)) { [weak self](user, error) in

抱怨它无法编译,因为它期待AppCredentials(username: username!, password: password!) 即使 AppCredentials.init(googleToken 是返回 RLMCredentials 对象的有效调用

标签: iosswiftrealmgoogle-signin

解决方案


推荐阅读