Android Firebase – 无需身份验证即可存储数据

我正在使用Firebase制作一个示例笔记应用程序,用户可以登录并创建简单的文本注释.
我的Firebase数据结构如下:
"Project-dir":{
    "Notes":{
        "UserID":{
            "NoteKey":{
                "title":"This is note title","content":"This is the note content","unixTime":123456789
            },"NoteKey":{
                "title":"This is note title",}
    }
}

它可以在用户登录时正常工作.
但是,我想添加“继续不登录”功能.我使用push()生成唯一的用户ID,而不是使用auth UID并存储在sharedprefs中.
但是,当他决定稍后登录时,如何将所有这些笔记迁移到用户的UserID(UID)?

解决方法

对于这个特定用例,您将要使用 the Anonymous Authentication provider of Firebase Authentication.

它与现在基本相同(它为当前用户/设备生成随机ID).不同之处在于您可以通过链接他们的Facebook / Google / Github /电子邮件帐户来获得upgrade the anonymous authentication user to an identified user.

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...