当前位置:  开发笔记 > 编程语言 > 正文

FirebaseInstanceId-每个Firebase“应用”或Android应用唯一?

如何解决《FirebaseInstanceId-每个Firebase“应用”或Android应用唯一?》经验,为你挑选了1个好方法。

我创建了一个小型Android应用程序,该应用程序应创建唯一的userIds

我正在考虑使用FirebaseInstanceId.getId()它,因为文档说

返回一个唯一标识应用程序实例的稳定标识符

但是app在这种情况下是什么意思呢?

是否app表示使用的“真实” Android或iOS App FirebaseInstanceId?还是说它是“火力地堡App”或更好的火力地堡Project

我可以假定生成的id内容在我的Firebase项目中是唯一的,并且可以存储FirebaseDatabase为,userId还是应该userId以其他方式创建唯一的内容?



1> Doug Stevens..:

You can infer that the "app" in this case means a particular app installation on a device. Look at the javadocs for FirebaseInstanceId, and take note of the rules for when an instance id can change. Install/uninstall and clearing app data are a result of user behavior against an app on their device. Note that this value can change, and therefore probably isn't appropriate for uses outside of Firebase.

This value is used by Firebase for identifying an app that could receive a cloud message. It does not represent a particular user. A user could have the same APK installed on multiple devices, using a single account to log into each one of them. If you want to send that user a cloud message, which instance of the app should it go to, on which device? You probably want to send to all of them. That's where instance id comes into play. In order to preserve consistent behavior of your app, no matter how many times it's been installed for a user, you need the instance id of each unique installation in order to target a message to all of them.

要识别特定用户,您应该使用Firebase Authentication,并假设他们每次都将登录同一帐户,因此您可以存储一个UID来指代该用户。通常,将多个实例ID与单个用户相关联,以便针对该用户定向消息传递。

推荐阅读
Life一切安好
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有