Getting a Code to Run at a Specific Time of Day Even if App is Off.

Hello, I am using the code below in order to query the correct time on a server. Its a 24 hour timer that never stops. It is working perfectly and I am displaying the correct time on Unity editor with no errors. Except, the problem is I need this timer to run a specific code at exactly 24.00:00 every single day - I mean it works, except you have to be on the app running the scene in order for it to work, which makes sense. How do I get it to run the code at 24.00:00 even if the app is off?

For Example - Lets say you press a button at 21.00:00 and the button disappears. And the only way for the button to reappear is if the timer passes 24:00:00. With the code below you would have to be on the app on the scene at exactly 24.00:00 to turn the button back on. How do I get the button to reappear, when it passes 24.00:00 even if the app was off. So if they get on at 2.00:00 the button is back on and if they press the button again it disappears and they have to wait until the timer hits 24.00:00 for the button to turn back on again but they don’t have to have the app open.

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;

     public class Timer : MonoBehaviour {

public Text myText;
string url = "";

void Update () {

	WWW www = new WWW(url);

IEnumerator WaitForRequest(WWW www)
	yield return www;
	// check for errors
	if (www.error == null)
		Debug.Log("WWW Ok!: " +;
		myText.text =;

		if ( == "24.00:00") {

			Debug.Log("CODE I NEED TO RUN");


	} else {
		Debug.Log("WWW Error: "+ www.error);


You cannot. Imagine if any developer could start his app without your agreement.

What you can do is store the time when the user quits and when he comes back compare the elapsed time. If more than x min/s/h/days then perform appropriate action, in your case show the button.

Or you can send notification which is the way most do. You know those annoying bling in the middle of the night to let you know you have refill your heart. But even for those a user may not allow them.