OnDisconnect() nerver fire

时间:2019-05-06 03:31:52

标签: android firebase-realtime-database

as the title, I use OnDisconnect to make presence feture. I did a test :

  1. I open app when has internet connection -> it works fine and the user online now.
  2. I turn off the internet ( both Cellular and Wifi ) and close the app -> the OnDisconnect should fire in a few minutes, but it did not.

I read this post : Firebase: when onDisconnect event fire?

是什么

@Frank说:“所以在这种情况下,您只需要多一点耐心即可。”但是我已经等了一个小时,它仍然没有启动。

那么我们应该等多久呢?至少我们怎么知道它会发射还是不发射?

这是我的代码:

  if (getMyUID()!=null){
            ROOT_REF.child(CHILD_USERS)
                    .child("userid")
                    .child("active").setValue(Calendar.getInstance().getTimeInMillis()+"");

            ROOT_REF.child(CHILD_USERS)
                    .child("userid")
                    .child("active").onDisconnect()
                    .setValue(Calendar.getInstance().getTimeInMillis()+"");
        }

0 个答案:

没有答案