How to minimize a mobile native app programmatically?

0
Hello experts I have an offline-first native mobile app that uses a lot of data (the client is a company in which the uses must use the app on the countryside with no or poor internet connection). In order to avoid the full sync when lauching the app, it’s recommended to not proceed with the logout. Also, my idea is to use the AppEvents On Resume to require the biometric authentication,avoiding in this way access to private data. My question is: is there a way to minimize the app programmatically? That is, in my app there will be two options to “close” the app: Close (minimize the app) and Exit Session (doing the logout and wiping the local database) 
asked
2 answers
1

Hello All,

 

Just as a follow up, to minimize/exit the app from any page, you can use a custom JSAction as shown below:

 

here is the JSAction code:

// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import "mx-global";
import { Big } from "big.js";

// BEGIN EXTRA CODE
import { BackHandler } from 'react-native';
// END EXTRA CODE

/**
 * @returns {Promise.<void>}
 */
export async function ExitAppJS() {
	// BEGIN USER CODE
	BackHandler.exitApp();
	// END USER CODE
}

credits to @Willian Oliveira to point me this solution. Thanks Bro!

 

 

answered
0

When the user does not sign out but only kills the app, the data is retained. On a licensed node, the app will not reload any data when the app is opened with a user still logged in. Note that a sandbox is seen as dev environment so a native app built against a sandbox node will require a connection to the node at startup. So killing the app should be sufficient. You might use AppEvents widget to force a biometric check after app is in the background for x minutes. Note that devices can kill backgrounded apps when the device needs the resources.

answered