How to do something when the user presses the home button and then reopens the app

I was wondering how you would make your app do something when it reopens from a soft close?

Maybe something like this:

void OnApplicationFocus() {
    if (softClose) { 
        // do things
    }
}

void OnApplicationPause() { // may have to be OnApplicationQuit, there's something funny there I can't remember
    softClose = true;
}

That way the OnApplicationFocus call only gets run if your app reopens. If they’re launching for the first time (or if it the process is killed) the flag would be reset. Assuming you want this to only run while the app is still in memory/open. Swap that out for a PlayerPrefs variable if you want it to persist through killing the app.

The OnApplicationPause function has a parameter, you can use that too, like this.

function OnApplicationPause(pauseStatus: boolean)
{
	if (!pauseStatus)
	{
		// do stuff here
	}
}

what about OnEnable

OnEnabled is called when an object becomes enabled and active, means it will be called when a level is first loaded or if you set an object active from inactive state. As you want to do something when the user re-opens the app, OnEnabled is not the right place to do so.