How To Use Os.date() To Schedule App To Turn Off?

Hi WilerJr,

I see what you mean, but it’s not so much the user that I’m worried about (thinking it’s a crash)… it’s the marketplace “gatekeepers”. This will likely be considered an undesirable feature, and your app will be rejected.

 

Why not just kick the user back to a title screen or something? You can do that by simply running a timer and controlling it (pausing it, restarting it, etc.) during various system events if necessary.

 

Brent

That’s sad to know…

 

I need the game to turn off automatically to save user’s battery. What I mean is that the user may not be paying attention to the device (I hope you understand) to close the app and his device’s battery will be affected. I want the app to play its songs and count the minutes the user chooses even if the device is suspended; it’s a feature I really need inside my app. Do you understand that?

 

Thanks.

Ah, I see… well then, if the reviewer understands this, hopefully it will pass approval. In regards to testing the local notifications, did you follow the entire process in the URL I mentioned above? And more info here: http://docs.coronalabs.com/api/library/system/scheduleNotification.html

 

This should set up a local notification after a specific time (as you want) and then you can trigger the app exit using “os.exit()”. I mainly wanted to bring to you attention that a forced app exit is generally not considered “usual practice”, so it might raise flags on the approval side… but maybe not. :slight_smile:

I hope they understand! :smiley: haha

 

Yes, Brent. I have understood the scheduleNotification API, but I need a method where my users will have choice to enable the shutdown schedule timer and, if they want, to disable the timer, do you get it?

I don’t know there’s a way to do that, but I’m trying. I’m asking for help because I don’t want to keep trying to discover a thing which has no way to be implemented, then I can focus on other features of my app.

 

Thanks. :slight_smile:

Is the “system.cancelNotification( notification )” API sufficient for this need? It cancels any active notification timer. Usage of this is described in the tutorial.

I’ll try. But it seems there’s not a printable value for timer = os.date("!*t", os.time() + 60); ,right?

Hi @WilerJr,

Since you’re dealing with time, have you read the following tutorial? It should be useful to your scenario:

http://www.coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Wow! I haven’t read that yet! I’ll take a deep look inside that. I’m almost sure that will help a lot.

Thank you, Brent.

Does system.scheduleNotification work on simulator, Brent? If yes, it’s not working here.

Brent?

Hi @WilerJr,

Oops, I almost forgot to respond to this. You’ll need to test “system.scheduleNotification” on a device, not the Simulator.

Take care,

Brent