使用当前用户电子邮件设置值 [英] Set Value with current User Email

查看:38
本文介绍了使用当前用户电子邮件设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将当前用户电子邮件作为子级保存数据,但是当我启动我的项目时,应用程序崩溃,并显示以下错误消息:以 NSException

I want to save data with the current user email as the child but when I start my project the application crash with this error message: terminating with uncaught exception of type NSException

let email = Auth.auth().currentUser?.email
let SavedProduct : [String: Any] = ["email": email, "ImageURL": FImage1[picturenumber]]
Database.database().reference().child("SavedWoman").child(email!).setValue(SavedProduct)

推荐答案

您不能将电子邮件地址用作Firebase数据库节点的密钥,因为这些密钥不能包含句点,而每个电子邮件地址至少应包含句点其中之一.

You can't use an email address as the key of a Firebase Database node, as those keys can't contain periods, while each email address contains at least one of those.

常见的解决方案是以某种方式对电子邮件地址进行编码.最简单的编码是将.替换为 ,Firebase密钥中允许 ,并且通常不会在电子邮件地址中出现

The common solution is to encode the email address in some way. The simplest encoding is to replace the . with a ,, which is allowed in Firebase keys, and conveniently can't occur in an email address.

所以 jan2409@someaddress.com 会变成 jan2409 @ someaddress,com .

这篇关于使用当前用户电子邮件设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆