ios - Firebase Google 登录崩溃 Swift
<p><pre><code>@IBAction func GoogleLoginDidTapped(_ sender: Any) {
print("Google login completed")
try? GIDSignIn.sharedInstance().signIn()
try? GIDSignIn.sharedInstance().uiDelegate = self
try? GIDSignIn.sharedInstance().delegate = self
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
try?auth(authentication: user.authentication)
}
func auth(authentication: GIDAuthentication)
{
let credential = FIRGoogleAuthProvider.credential(withIDToken: authentication.idToken , accessToken: authentication.accessToken)
FIRAuth.auth()?.signIn(with: credential, completion: { (user, error) in
if error != nil{
print(error?.localizedDescription)
}
else
{
print(user?.email)
print(user?.displayName)
x = true
name = (user?.displayName)!
self.movespecial()
}
})
}
</code></pre>
<p>我可以登录,但是当谷歌窗口打开时,如果我点击完成,应用程序就会崩溃。有人能帮帮我吗?提前致谢。</p>
<p>我已经在这个应用程序上工作了一段时间,这是最后一步。
我得到的错误是</p>
<pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我找到了解决办法</p>
<pre><code> func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if error == nil
{
auth(authentication: user.authentication)
}
else
{
print(error.localizedDescription)
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - Firebase Google 登录崩溃 Swift,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/42755246/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/42755246/
</a>
</p>
页:
[1]