ABOUT THE WEBINAR
Most mobile apps rely on network connectivity to provide a smooth user experience and working functionality. A loss in connectivity could mean a loss in efficiency - users may not be able to finish their task or risk losing data. Offline apps give your users the flexibility to use your app uninterrupted even when connectivity is not always available. With nanoflows, you can easily model application logic that doesn’t require a connection, and build an offline app in minutes!
Danny will bring you up to speed on the latest and greatest features from our vision for offline mobile apps, and how Mendix supports you through the app development process. Typical use cases for offline apps are inspection or event apps, but to make it more fun Goncalo will demonstrate another cool use for offline apps – gaming! While building an offline version of Mastermind, he will show you how to create your first offline app, model logic using nanoflows, instant app preview, customizing introduction screens, and installing the app on your device.
During this webinar we will cover the following topics:
- Offline mobile applications
- Best practices
- Modeling an offline app
- Testing an offline app
- Installing an offline app
QUESTIONS & ANSWERS
I have 3 entities Country, City, Street. Can you explain how I can add constraint to see only the streets that are in the city that I selected when in offline mod?
Data is already automatically constrained based on entity access so you only see the data that you’re allowed to. If you are talking about restraining data shown in the UI, there are several approaches:
- You can use navigation over association, or only show the associated objects.
- Or, you could use a nanoflow to filter the objects to constrain it.
When will Mendix add nanoflow as a datasource in the dataview?
There are plans for this but we do not have a definite date for its release. As a workaround, you can use a list view with a nanoflow as the datasource that returns only one item.
In an online app, does the performance of microflows and nanoflows differ?
For more information about the differences between microflows and nanoflows, see https://docs.mendix.com/refguide/nanoflows#2-when-to-use-nanoflows
What happens when I have both an online and offline app profile, but when I am working online, I step in an elevator and my connection drops?
When you build the app you specify whether it is an offline or online mobile app. This determines how the app will behave when there is no connection or if connection is limited. When you build an offline app, and ensure that you have selected the offline profile, it will always work regardless of connection. However, if you build it like an online app, and you lose connection, and depending on what you are doing in the app, you will get a connection error message.
Will synchronization pick up entities several pages and nanoflows deep?
The Mendix Modeler analyzes your full offline profile with all pages and nanoflows included in it. All the entities that are used in these pages and nanoflows will be synchronized to your mobile app.
If any issues occur while syncing offline data to the server, is it possible to recover the data?
Synchronization is one transaction, meaning that synchronization will work fully, or not at all. If during synchronization an error occurs, the data will be kept at the device and will not be committed to the database on the Mendix server. This means that you can retry later when you have a more stable connection.
Can you set default values to attributes when you create a new object in offline mode?
Yes. When you create an object in a nanoflow you can immediately specify values. When you sync or create an object node, the default values are automatically filled in but you can add them easily in nanoflows in the Create Object activity.
Would syncing data after you regain connection be a manual action?
Yes, it is.
Is it possible to convert an already existing app to an offline app, and what are the main steps to consider? Is converting microflows to nanoflows sufficient?
Online and offline apps are fundamentally different. With offline apps, you need to think about the data you want on your device. Also, nanoflows and microflows have different characteristics, you can still copy and paste activities, but you still need to be aware of the differences between retrieval and how this effects your data. For example, with an online app, you retrieve data from the Mendix server. With an offline app, the data is retrieved from the local database, meaning you could have two very different results in terms of which data you want show. So, while you can re-use a lot of things to move from an online to an offline app, it’s not as simple as flicking a switch! You really need to think about and consider the design.
How is data from a web service handled in offline mode? For example, weather or time table information. Should you save the values locally before?
In offline apps you should think about the data you need to have available. In this case you need to cache the data already there. You can also trigger a sync that will pull new data which you can then use in your offline app.
In the initial explanation about nanoflows you mention that commit is not part of a nanoflow. But there were a lot of commits being used during the demo. Could you elaborate on the use of commits in nanoflows?
You can use commit in nanoflows in an offline app to commit directly to the local database. But you can also use nanoflows in online apps, which can be very powerful for dynamic UIs or fast validations. When you perform certain database related activities in an online app, such as commit, retrieve, or rollback, you create a call to the server. If you use a nanoflow in an online app and use a commit it also does a call to the server. One call is fine, but multiple types of these activities mean that there are multiple calls to a server. With microflows there is always only one call to the server, so in this case it may be more performant to use a microflow instead of nanoflows. So you can commit, but be aware of when to use commit in a nanoflow when you are using it in an online app.
In offline mode, when you commit, where does the data commit to?
All the data that you use in an offline app is stored in a local database that is stored on your device.
Do you advise making a specific online workflow, with an online navigation profile, and a specific offline workflow, with an offline profile?
Yes, this depends on your use case. When you start to build, you need to think about the circumstances in which your app will be used and make a decision based on that.
Is it possible to detect which objects have been synchronized? For example, if new contacts have been added whilst I was offline. Can a nanoflow display just those new contacts to the user?
Yes. You can use the Is Synced function in the nanoflow expressions to determine whether an object has synced or not.
Does offline data automatically sync with the server when the app comes back online?
Currently you need to invoke synchronizations manually. This can be done by pull to refresh gesture, or sync button or saving.
Is there a way to limit the database size that will be downloaded to your device, besides entity security?
No, currently it is based on what you model and based on entity access. This year, we will provide more flexibility regarding the which data will be synchronized to your mobile app.
What is best practice for synching data?
Best practice is to always consider the type of data and the amount of data you want to sync.
So, the best practice is an online app or an offline app, but not both functionality in one app?
It’s a choice. You choose either online or offline, it is not both functionality in one app. The best choice depends on your project and what the circumstances of the use case is. If the app is used with a lot of online interaction, and is used to extract data from a lot of online services, and there is always good connectivity, then online app is the best choice. However, if the app always needs to work regardless of connection and it’s not always guaranteed that there will be a good connection, then offline apps would be more suitable for this case.
If future, we will take online and offline apps in the direction of dual functionality where you won’t notice whether an app is online or offline.
View more webinars on-demand at developers.mendix.com.