UIApplicationExitsOnSuspend

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

UIApplicationExitsOnSuspend

Post by marksmithhfx » Sat Sep 05, 2020 1:04 pm

Since UIApplicationExitsOnSuspend is now unsupported by Apple, are there any LC messages that can be received which indicate the state of the app is going into the background or being suspended? I am looking for something that can replace the previous UIApplicationWillResignActiveNotification which now no longer seems to receive anything (probably because all apps are now staying open in the background and not actually quitting). This presents a tricky situation if you want to save changes to a DB before being moved into the background.

Any suggestions?
Thanks
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: UIApplicationExitsOnSuspend

Post by jacque » Sat Sep 05, 2020 6:42 pm

This has always been the case on Android, where apps always run in the background unless the user specifically quits or the OS shuts it down. The only solution is to save everything as it happens, since you never know when you'll lose control. That may not help with notifications but the database would be saved.

If the OS does shut down the app, you should get a shutdown message which might help.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: UIApplicationExitsOnSuspend

Post by marksmithhfx » Mon Sep 07, 2020 10:08 am

jacque wrote:
Sat Sep 05, 2020 6:42 pm
If the OS does shut down the app, you should get a shutdown message which might help.
Brilliant! Thanks. That is one scenario I had not tried. I have a test app with the full compliment of "shutdown" type handlers that just writes a small text file to the documents folder if one is triggered. So far nothing has showed up, but I had not tried powering off since I added UIApplicationExitsOnSuspend. That might actually work. It would be a solution since the only data loss I'm seeing is when I power off the device. If that could be trapped...

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: UIApplicationExitsOnSuspend

Post by marksmithhfx » Mon Sep 07, 2020 1:37 pm

jacque wrote:
Sat Sep 05, 2020 6:42 pm
If the OS does shut down the app, you should get a shutdown message which might help.
Hi Jacque,

Well, great suggestion, unfortunately, no luck. I have Shutdown, CloseStack, and UIApp.... handlers in stack, card and front/back scripts and so far the only way to create my little test file is with a button press. I'll see if tech support can provide a list of all of the "app status" messages we are supposed to receive, and if none look suitable I'll make an enhancement request to implement a "going into background, suspended or woken up" message.

Cheers,
M
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: UIApplicationExitsOnSuspend -- Solved

Post by marksmithhfx » Fri Sep 11, 2020 3:30 pm

Due to some excellent detective work by Elanor (thank you!!), she discovered my app was not automatically including mergNotify during the build. This was the cause of UIApplicationWillResignActiveNotification not working. Once that was added manually, it worked and I was able to "go into the background" gracefully by updating the db before closing it. This does of course mean that I have to re-open it again when my application is brought to the fore, but there is a complimentary notification UIApplicationDidBecomeActiveNotification which should handle that nicely (as yet not tested, but I don't see why it shouldn't). I just thought I should let everyone know what mergeNotify messages are working correctly on iOS, but you may want to check your inclusions if you are experiencing any difficulties.

Oh, and it also works on power-off which an added bonus.

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

Post Reply

Return to “iOS Deployment”