Hi,


I am creating a mobile app with offline functionality and i am using the offline data sync. I have configured the data sync to start when the device comes online.

When i am using the application, turning off the internet connection it knows it is offline ( I show a container with the GetNetworkStatus() function. 


When i turn on the internet again, the application will not reconnect to the internet and seems to believe that it is still offline.


Anyone has ever experienced this before?

Hi Bas de Jong,

and you implemented this all steps from the document Implementing Offline Sync ?

This block NetworkStatusChange (from Mobile Patterns), you should place it on the layout, and bind an event handler to this event.  

Then you should have a local variable to map the result of that event. This event is triggered every time that is a transition between online -> offline and the opposite.

With that local variable you can bind it to an if statement or trigger a different event to be handled at the page level.


Can you confirm if you have all this steps?

Note: The GetNetworkStatus() returns true if the device is connected to any network (Wi-fi, 3G, 4G, etc). It does not check if there is actually internet connectivity.


Cheers,
Nuno Verdasca


Nuno Miguel Verdasca wrote:

Hi Bas de Jong,

and you implemented this all steps from the document Implementing Offline Sync ?

This block NetworkStatusChange (from Mobile Patterns), you should place it on the layout, and bind an event handler to this event.  

Then you should have a local variable to map the result of that event. This event is triggered every time that is a transition between online -> offline and the opposite.

With that local variable you can bind it to an if statement or trigger a different event to be handled at the page level.


Can you confirm if you have all this steps?

Note: The GetNetworkStatus() returns true if the device is connected to any network (Wi-fi, 3G, 4G, etc). It does not check if there is actually internet connectivity.


Cheers,
Nuno Verdasca


Hi,


I followed the steps from the Offline Sync guide. I did not know that the networkstatus change block exists. I have implemented it now, however, how do i determine the default value if the app is online or offline. If i start the application when i have no internet connection, it should be online=False but the block does not generate an event because the connection does not change.

 I also need to detect what the initial value is. But if i do that in the layout block, it will do this every time i change a screen in the application. 


Do you have an implementation for this?


Kind regards,

Bas


PS: Thanks for the note about the getnetworkstatus() because i assumed that this also tested if there was a connection possible.



Sorry it still does not work right

Default it will say that the application is in offline/online state but this is not checked anywhere. How can i set a default value for this when the application is opened?

Hi Bas de Jong,

I'm trying to understand what miss in your code, If you followed everything here, validate if you made this logic:


Regarding the webblock being in the layout, this is important since at any time you can run out of network, so with each rendering of the application it will validate if there are any network changes from the previous ones, and if the change is from offline to online, An event is triggered to proceed with the synchronization logic of everything you set in the Sync functions.


I leave some configuration images (first two) and three others of usage examples.




Cheers,
Nuno Verdasca

Hi Nuno,


Thanks for the comprehensive descriptions. Everything is the same as you described.


However i am interested in what happens if there is no connection, and you open the application. 

Because how you describe it now, the web block in your bottom bar only puts out an event when the connection changes. But i need to know the initial state. (If the app was opened while offline or while online).


What do you use as default value for the NetworkIsOnline local variable in your Bottombar?

Hi Bas de Jong,


about this question "What do you use as default value for the NetworkIsOnline local variable in your Bottombar?":

  • True


To validate the startup, I would put the validation logic whether we are Online or Offline on a splash screen, and if we were offline, I would put the flow going from the Splash screen to an offline informational screen that could inhibit the use or not. depending on whether it was the first time you entered the application or not entered for some time, in case you don't have your local storage filled or too old. This is all a suggestion, a possibility. Did I answer your question? I'm trying to help you....

The initial state, it detects whether or not the device is online, updates the variable if necessary, and in agreement with the variable, you know the state at that time.


Cheers,
Nuno Verdasca



Hi. 

You can check the initial network status by doing a GetNetworkStatus() in the BottomBar OnInitialize event and store the value in a local variable. 

Then, whenever there's a NetworkStatus Event, you can update the local variable value with the event handler input value 

If you want to have more control over the GetNetworkStatus(), you can also add a SetInterval to your bottom bar to check every x seconds what's the current network status.

Gabriel Cardoso wrote:

Hi. 

You can check the initial network status by doing a GetNetworkStatus() in the BottomBar OnInitialize event and store the value in a local variable. 

Then, whenever there's a NetworkStatus Event, you can update the local variable value with the event handler input value 

Is there a performance impact in doing this? Because the Bottombar gets initialised on every screen.

Solution

Bas de Jong wrote:

Gabriel Cardoso wrote:

Hi. 

You can check the initial network status by doing a GetNetworkStatus() in the BottomBar OnInitialize event and store the value in a local variable. 

Then, whenever there's a NetworkStatus Event, you can update the local variable value with the event handler input value 

Is there a performance impact in doing this? Because the Bottombar gets initialised on every screen.

This is what I have been trying to tell you in my answers before Bas de Jong. Regarding the botton bar being rendered on all screens, that's the idea, and so I told you that a hypothesis could go into the application layout. The idea is that this function with each scenario change, each render is called to see if there has been a change in status on the network.


Solution

Okay! Thanks for all the replies!