I am implementing firestore database in my android application, before I go to live I came to a new issue that is multiple device login, for short if User is logged with single email Id to multiple devices that I want to allow an only single device that can access the database at the time. I searched and found firestore rules

service cloud.firestore {
  match /databases/{database}/documents {
    match /<some_path>/ {
      allow read, write: if <some_condition>;

but I am not much aware of server-side code, can anyone help me with this.


You can't control access to Firestore based on the device. You can only control access using the UID of the account that the user logged into using Firebase Authentication. That user will be able to read and write data according to your rules from any device where your app is installed.

  • Thanks for valuable info, is there any other way for achieve this? – Hemant Parmar Jun 7 at 11:59
  • No, as I said, you can't control access to Firestore based on the device. You can try to write some code in your app to check a device ID somehow, but it won't be secure. – Doug Stevenson Jun 7 at 12:02

Nothing is built in to Firebase for allowing each user to only access your database from a single device.

You could build something on top of Firebase yourself, but I'd seriously consider whether it's worth the effort. See previous questions on this topic for the Firebase Realtime Database:

  • Thank you for valuable info @Frank van Puffelen! – Hemant Parmar Jun 10 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.