[Done] Offline mode apps

As far as I know, the only way to have “offline” apps is to have a dedicated server onsite. I’d like to have standard “offline” apps on the client side that can re sync to the server when back online. This would be a game changer for my company (Currently in warehouse logistics and security), and I’m sure many others :slight_smile:

8 Likes

+1 to this… I would do +10 if I could!

2 Likes
1 Like

If users already have a way to enter this information locally, then you may want to look at Anvil’s Uplink feature. This would let you update your Anvil tables with the locally-entered information.

3 Likes

+1
Would really like to start developing my app with anvil but offline is a must. Is it on the roadmap?

1 Like

Here’s something that might work, I’ve not tested it.

If you can start the app in reach of the server and keep the required offline data entry all client side, then the app might well continue to run without any server connection.

You could then wrap a server “ping” on a timer inside a try block to see if the server is back in reach, and you could then sync.

You may have to set the default error handler to trap any attempts the anvil client might make to contact the server itself (the docs will help you with that).

Just an idle thought.

Ok, my idea above works on a simple test. I’m just multiplying a number by 123, but it involves some interaction. I then switch my phone into airplane [they are aeroplanes!] mode and it continues to work.

edit - ok, looks like the timer stops firing when the network is lost, which is a different issue, but it does then fire when the connection is back, so amounts to the same thing really.

1 Like

Have you tried keeping the phone offline for more than 30 minutes?

I am wondering if the server closes the connection after not hearing from you for 30 minutes.
Perhaps it is possible to automatically reestablish the connection and refresh, but this is something to keep in mind.

Interesting! This could work for now.

Adding some html to warn the user before refreshing the page could be useful here too. Did a quick test and this seems to work on mobile at least! Just need to modify to only issue the warning if the connection is lost.

<script>
// Warning before leaving the page (back button, or outgoinglink)
window.onbeforeunload = function() {
   return "Do you want to leave?";
   //if we return nothing here (just calling return;) then there will be no pop-up question at all
   //return;
};
</script>
1 Like

No, not yet. I will try that when the working day is over.

This would be amazing!!

1 Like