How to make a mobile app stay alive in the background?

J. Landman Gay jacque at
Mon Apr 27 02:25:57 EDT 2020

On 4/26/20 4:43 PM, Graham Samuel via use-livecode wrote:
> I notice in the Standalone Settings for iOS in LC 9.5.1, a button ‘Background Execution’. If I click it, I get a warning that I don’t really understand which suggests that LC doesn’t officially support the feature. I’m not even sure if this feature is what I need.

You are probably running an older version of LC since that checkbox has been removed recently. 
iOS now runs all apps in the background, much as Android always has, and if you use that 
checkbox now the App Store will reject your app. The deal is, the OS will keep the app in the 
background until it needs RAM for something else and then it dumps the app. There's no telling 
when that will happen.

This came up yesterday in the forums. The poster wanted his app *not* to run in the background 
after a certain amount of time. We get no messages once the app goes into the background, the 
only message sent is "shutdown" when the app gets wiped by the OS. In the meantime, the app 
becomes inactive if it isn't frontmost.

Other apps seem to be able to manage this better, so it seems there's something available that 
LC doesn't support.

The imperfect workaround, such as it is, is to write everything to disk that the app might 
possibly need if it suddenly stops. When it comes to the front again, reload everything and 
carry on (you'll get an openstack message when that happens.) For example, if your app has a 
login screen then you'd need to store the credentials on disk and automatically log the user in 
when the app restarts. Provide a "log out" button so they can quit on purpose; it would delete 
the credentials from disk so they'd need to log in again next time.

Basically you have to save the user state repeatedly whenever anything significant changes, in 
case the app goes dormant.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the use-livecode mailing list