How can I check Realm Object Server is offline or online(Swift/iOS)?


I got a problem , i would like to get server connect state when my device connecting the wifi ,because some time WIFI AP no internet connection or bad network , i would like to stop user to do someting.
I try to use the syncSession.connectionState,but always response “connected”.

func checkState(){
if let syncSession = syncUser?.allSessions().first{
switch syncSession.connectionState{
case .connected:
case .connecting:
case .disconnected:
view.isHidden = true