Lennert's experiment: an indispensable tool in a game of pétanque
The winner of a game of pétanque (a lawn bowling game similar to bocce) is normally decided by measuring the distance between the small target ball (officially called a jack) and each thrown ball (boule) with a piece of string. Or you can use Lennert's latest build. Lennert has developed a Power App that can measure the distance between two objects based on the Mixed Reality measuring component. You open the app and press "Measure", the camera opens, you position your phone above the playing area, and you measure the distance to the different boules with the app rather than a piece of string. You can also add pictures of the winner's happy face or that of the frustrated loser. Unlimited fun!
4 indispensable steps when developing a mobile app with offline functionality
- Build in a check that makes the app verify whether there is an internet connection.
- If the app is online, make sure it retrieves the latest data to synchronize with SaveData(). To optimize your app's performance, build in an extra check that ensures the app only synchronizes if there have been any changes since the previous synchronization.
- If the app is offline, make the app display local data with the LoadData() function.
- As soon as the app goes back online after an offline session, it has to synchronize again. You can ask the user to manually indicate that this should happen, you can set it to happen automatically, or you can show a pop-up asking if the user wants to upload. Which option you choose depends on the app's context of use.
- The updates happen with the Patch() function, which sends new or modified items back to the data source. For many items, this can take a long time and the user will have to keep the app open. If it takes too long, you can send items such as JSON to Power Automate, which is usually faster.
- Once the data source has been updated, let the app create a new local copy with SaveData(), so that the user will be able to use the most recent data in their next offline session.
Extra tips from our experts for a smooth offline experience
- Don't lose sight of the UX. A clearly visible icon shows your user when the app is online or offline, so they know which functions are available. You can also gray out and disable certain buttons with the "connection connected" function when they are not available. When the app is offline, you can show when the last data synchronization took place.
- Bear in mind the device's available storage capacity, which is limited. The available memory for Power Apps is generally around 30 to 70 MB.
- Attachments that have been added offline are not available out of the box for online storage. You should therefore advise users to take photos with their camera and upload them only when they are back online. Do not offer the option to add photos directly in the app.
- You can use the timer component to synchronize periodically, every 5 minutes for example. This allows you to perform some functions automatically to push or store data.
- Only sync data that is absolutely necessary for the user. This will achieve shorter loading times, better performance and less mobile internet usage.
- Don't forget that many Power Apps functions work in offline situations by default. Lennert's pétanque app, for instance, will work as normal. The online/offline context only matters when you want to save the results online.
- To avoid the creation of two versions when one user is online and another is offline, you can build in a "lock" function that ensures only one person can use an item. Or you can have the app check whether any modifications were made by someone else based on the timecode when an item was last modified.