In the method that handles the replication, I’m just showing/hiding a loader based on the status.
So, it hides and shows due to that temporary offline status info that comes saying the replicator’s status is == offline
Checking the documentation this is what offline stands for:
/**< The remote host is currently unreachable. */
So, the main issue is: If we receive “offline” we assume the server is not reachable/noConnectivity and we hide the spinner and display an error message. So, it seems we can’t rely on these statuses to check if the server can be reached or not.
For a future version, it would be nice to have another replicator status named maybe “waitingToLoad” while the replicator is set up. Then if there is an error it could return “offline” or the other statuses if everything is going ok.
If we receive “offline” we assume the server is not reachable/noConnectivity and we hide the spinner and display an error message.
If replication is initiated by the user, like by pressing a “Sync” button, that’s OK, but not if it’s just happening normally as part of running the app. CBL is designed to support offline operation, and it would be annoying to have an app pop up an error alert just because you opened it while in an elevator / on the subway / whatever.
What I would do is start a timer when you get the Offline status, and cancel it when you get a different status. When the timer fires, after 5 seconds or so, display the error alert.
Also, note that “offline” means that the device has no Internet connection. Literally it means that no network interface is able to route packets toward the destination IP address. You’ll get this in Airplane Mode, if an iPad has no WiFi connection, or if an iPhone has no WiFi or cellular. It will not happen if the WiFi base station can’t reach the Internet, if your ISP is having problems, or if the server is down. In those cases you’ll get a Stopped status with an error after 30 seconds or so.
Couchbase Lite 2 behaves more like this. There is a new status called “Connecting” that you’ll see while the connection is being established, and you shouldn’t see “Offline” unless there really is no network connectivity.