Firebase onDisconnect broken in flight mode

So, I create a presence in my application by setting a flag in firebase called isOnline to true when the application becomes active and when I initialize the account. For the most part this works, the user is marked as offline when I kill the application. But when I go into airplane mode, my shutdown handler is never called, and the user still appears on the Internet.

After reconnecting, I do an action that writes to firebase, and with this record (maybe something at all), the isOnline flag is false. I'm a little confused.

This is how I work on the Internet:

 - (void)goOnline { Firebase *connectedref = [[[Firebase alloc] initWithUrl:kPULFirebaseURL] childByAppendingPath:@".info/connected"]; [connectedref observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) { if ([snapshot.value boolValue]) { Firebase *fire = [[[[[Firebase alloc] initWithUrl:kPULFirebaseURL] childByAppendingPath:@"users"] childByAppendingPath:[PULAccount currentUser].uid] childByAppendingPath:@"isOnline"]; [fire setValue:@(YES)]; [fire onDisconnectSetValue:@(NO)]; } }]; } 

I call goOnline in my application deletion when the application starts and when it becomes active. When the application goes into the background, still activity will be sent to firebase, so isOnline remains true as expected. Is it wrong to install the disconnect handler again if it is already installed (if activated)?

When the application terminates or background activity stops for 10-20 minutes, isOnline set to false, which is correct.

Is this the correct flow? Why am I encountering problems when working with a bad network connection / no?

+5
source share

Source: https://habr.com/ru/post/1213933/


All Articles