Skip to main content
Version: v11.9.4

Switching between Offline and Online Mode


9.2 release

Mobile Apps switch between online and offline modes based on the network connectivity. Apart from this, when an app uses offline DB and there is an intermittent network connectivity, the user should be able to decide when the offline changes need to be synced. In such a case, when the network is available, the user will be asked whether to connect to the backend server or continue in offline mode.

Online-Offline Modes

Following are the network scenarios and the state of WaveMaker apps:

The network is available

The app connected to the backend server

The app is in online mode.
The network is not availableThe app is in offline mode.

The network is available

The backend server is not available

The app is in offline mode.

Network and backend server is available

The app is not connected

The app is in offline mode.
(The app goes into this state when ‘goOffline’ operation is invoked.)
The app is trying to connect to backend serverThis is an intermediate state and app will be online or offline based on the success of the operation.

Implementation

A tag in index.html called ‘wm-network-info-toaster’ will display the network info toaster when there is app network status change. Messages shown in the toaster are part of the app’s localized messages. Following are the keys to these messages.

KeyMessage
LABEL_HIDE_NETWORK_INFOHide
LABEL_CONNECT_TO_SERVICEConnect
MESSAGE_SERVICE_NOT_AVAILABLEService is not reachable.
MESSAGE_NETWORK_NOT_AVAILABLENetwork not available.
MESSAGE_SERVICE_AVAILABLEService is available.
MESSAGE_SERVICE_CONNECTINGConnecting to server.
MESSAGE_SERVICE_CONNECTEDYou are online.

NOTES:

  • You can choose not to use this offline-online switch functionality. In such cases, you can remove the tag from index.html.
  • You can customize this functionality using the operations (getNetworkInfo, goOffline, goOnline) provided on ‘Device’ service. see here for more on device variables.

B.1 Mobile Apps