How to handle multiple connections of the same user on Firebase?

后端 未结 1 1855
一个人的身影
一个人的身影 2020-12-07 05:20

How to manage concurrent connections of the same user. Is there any way I can limit how many connections my user can keep active?

I could make my database something

相关标签:
1条回答
  • 2020-12-07 05:55

    To handle when the user connects, look at .info/connected. You could use this to set a flag when the user connects.

    To handle when the user disconnects (either by closing the app or because they lose their connection), look at onDisconnect(). You could this to remove the flag when the user disconnects.

    But why would you want to limit the user to only access their data on a single device? Firebase doesn't charge per connection, so why would you want to limit it on that?

    A few years ago I was using an app that exhibited this exact behavior and I found myself locked out of the app multiple times per day. I moved over to another app.

    0 讨论(0)
提交回复
热议问题