Suspend in iOS, or when is a mobile app running?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
Sorry if this is documented somewhere but I can’t find it.

On desktop platforms, LC gives us “suspend” which is fired when the app goes into the background. I seem to be having some problems with iOS, in that when the screen locks (triggered by  user action or a time limit), my app seems to stop getting messages from the OS, so is in some sense suspended. This seems to call for something like “suspend” for mobiles. Does such a message exist?

Another thing that happens with iOS apps that use Location Services is that the user is sometimes asked via a popu-up on the screen of the device whether the app should be allowed to use these services when it’s not running. I don’t know what triggers these user messages, nor am exactly certain what ‘not running’ means - presumably if the app has been properly quit, that’s something other than ‘not running’. In the Standalone Settings for mobile, one can set Location Services as being a requirement, but there doesn’t seem to be a setting corresponding to this user choice.

Has anyone a clear understanding of all this? I would love to see an explanation.

TIA

Graham
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
I’m not sure what you mean with ”suspend” on mobile. You only run one application at a time. If your app goes out due to a phone call or any other event it will normally quit your app and send a closeStack message and some more. If you want to create an application that doesn’t allow the screen lock to kick in you can do that via mobileLockIdleTimer, but don’t forget to unlock when you don’t need it anymore!

The first time you ask for location data the phone will pop up a message asking the user to allow location tracking (as that is a privacy feature). You need to check if you are allowed to track before trying to get location data. If the user disallows location tracking your app will never get any location data how much you even try!

An app can also ask for location tracking as a background execution task. This is where the user selects ”Always” instead of ”When app is in use”. Then your app might get location data even if it is not the front-most application. Then your app will still get locations change updates. This is available as an experimental feature under the ”Standalone Application Settings” for iOS. I say might, because you can never be 100% sure. If the user starts an app that requires all memory your app might still be thrown out and terminated, but iOS is really good at shuffling memory so it usually works. I haven’t tried this experimental feature though so I can’t say if it works OK in LiveCode, but if you have a device for testing you can give it a try!

Applications that will get permissions for always track location can also set up "location notifications”. Then your app will startup when you arrive or leave a specified location. E.g. this is how Remainders work when you set a Remainder to trigger based on location. E.g. When I leave home.

:-Håkan
On 17 Nov 2020, 16:26 +0100, Graham Samuel via use-livecode <[hidden email]>, wrote:

> Sorry if this is documented somewhere but I can’t find it.
>
> On desktop platforms, LC gives us “suspend” which is fired when the app goes into the background. I seem to be having some problems with iOS, in that when the screen locks (triggered by user action or a time limit), my app seems to stop getting messages from the OS, so is in some sense suspended. This seems to call for something like “suspend” for mobiles. Does such a message exist?
>
> Another thing that happens with iOS apps that use Location Services is that the user is sometimes asked via a popu-up on the screen of the device whether the app should be allowed to use these services when it’s not running. I don’t know what triggers these user messages, nor am exactly certain what ‘not running’ means - presumably if the app has been properly quit, that’s something other than ‘not running’. In the Standalone Settings for mobile, one can set Location Services as being a requirement, but there doesn’t seem to be a setting corresponding to this user choice.
>
> Has anyone a clear understanding of all this? I would love to see an explanation.
>
> TIA
>
> Graham
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
Android has always acted like this and now that iOS apps run in the
background like Android does, it behaves the same way. At least our
problems are cross-platform now.

An app will stay in RAM until the user specifically quits or until the OS
needs the memory. When that happens, the OS wipes the app and it
effectively shuts down. We get no warning, except for a shutDown message.
Android recommends we store the last state of the app and restore it when
it starts up again.

I'd love to get a message when the app goes into the background but so far
there is none. Storing every little change as it happens seems tedious and
wasteful. I haven't had much luck with storing changes on shutdown but it's
worth a try, it's been a while since I did it.

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On November 17, 2020 9:27:50 AM Graham Samuel via use-livecode
<[hidden email]> wrote:

> Sorry if this is documented somewhere but I can’t find it.
>
> On desktop platforms, LC gives us “suspend” which is fired when the app
> goes into the background. I seem to be having some problems with iOS, in
> that when the screen locks (triggered by  user action or a time limit), my
> app seems to stop getting messages from the OS, so is in some sense
> suspended. This seems to call for something like “suspend” for mobiles.
> Does such a message exist?
>
> Another thing that happens with iOS apps that use Location Services is that
> the user is sometimes asked via a popu-up on the screen of the device
> whether the app should be allowed to use these services when it’s not
> running. I don’t know what triggers these user messages, nor am exactly
> certain what ‘not running’ means - presumably if the app has been properly
> quit, that’s something other than ‘not running’. In the Standalone Settings
> for mobile, one can set Location Services as being a requirement, but there
> doesn’t seem to be a setting corresponding to this user choice.
>
> Has anyone a clear understanding of all this? I would love to see an
> explanation.
>
> TIA
>
> Graham
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
<Thanks to Panos for this tip:>

On iOS use mergNotify as below. Works well for me.

on openStack
 mergNotify "UIApplicationWillResignActiveNotification"
 mergNotify "UIApplicationDidBecomeActiveNotification"
end openStack

on UIApplicationWillResignActiveNotification pUserInfo
 // Your code before the app goes to background
 -- your code here to handle going to the background
end UIApplicationWillResignActiveNotification

on UIApplicationDidBecomeActiveNotification pUserInfo
// Your code after the app comes back to foreground
-- your code here to handle your app becoming active
end UIApplicationDidBecomeActiveNotification

Henry

> On Nov 17, 2020, at 10:54 AM, J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> Android has always acted like this and now that iOS apps run in the background like Android does, it behaves the same way. At least our problems are cross-platform now.
>
> An app will stay in RAM until the user specifically quits or until the OS needs the memory. When that happens, the OS wipes the app and it effectively shuts down. We get no warning, except for a shutDown message. Android recommends we store the last state of the app and restore it when it starts up again.
>
> I'd love to get a message when the app goes into the background but so far there is none. Storing every little change as it happens seems tedious and wasteful. I haven't had much luck with storing changes on shutdown but it's worth a try, it's been a while since I did it.
>
> --
> Jacqueline Landman Gay | [hidden email]
> HyperActive Software | http://www.hyperactivesw.com
> On November 17, 2020 9:27:50 AM Graham Samuel via use-livecode <[hidden email]> wrote:
>
>> Sorry if this is documented somewhere but I can’t find it.
>>
>> On desktop platforms, LC gives us “suspend” which is fired when the app goes into the background. I seem to be having some problems with iOS, in that when the screen locks (triggered by  user action or a time limit), my app seems to stop getting messages from the OS, so is in some sense suspended. This seems to call for something like “suspend” for mobiles. Does such a message exist?
>>
>> Another thing that happens with iOS apps that use Location Services is that the user is sometimes asked via a popu-up on the screen of the device whether the app should be allowed to use these services when it’s not running. I don’t know what triggers these user messages, nor am exactly certain what ‘not running’ means - presumably if the app has been properly quit, that’s something other than ‘not running’. In the Standalone Settings for mobile, one can set Location Services as being a requirement, but there doesn’t seem to be a setting corresponding to this user choice.
>>
>> Has anyone a clear understanding of all this? I would love to see an explanation.
>>
>> TIA
>>
>> Graham
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
And just a reminder that, under iOS, you’ll have to register to receive a “ UIApplicationWillResignActiveNotification” message, and then write a handler to respond to that (PS only register once in your stack script — I learned the hard way). It’s documented under mergNotify in the dictionary (with credit to Elanor for pointing this out to me when my “on shutdownRequest” handlers were being ignored).

Jacque, I believe this is what you are looking for to be notified when you go into the background. I do some db cleanup at that time and it seems to work.

Mark


> On Nov 17, 2020, at 6:54 PM, J. Landman Gay via use-livecode <[hidden email]> wrote:
>
> Android has always acted like this and now that iOS apps run in the background like Android does, it behaves the same way. At least our problems are cross-platform now.
>
> An app will stay in RAM until the user specifically quits or until the OS needs the memory. When that happens, the OS wipes the app and it effectively shuts down. We get no warning, except for a shutDown message. Android recommends we store the last state of the app and restore it when it starts up again.
>
> I'd love to get a message when the app goes into the background but so far there is none. Storing every little change as it happens seems tedious and wasteful. I haven't had much luck with storing changes on shutdown but it's worth a try, it's been a while since I did it.
>
> --
> Jacqueline Landman Gay | [hidden email]
> HyperActive Software | http://www.hyperactivesw.com
> On November 17, 2020 9:27:50 AM Graham Samuel via use-livecode <[hidden email]> wrote:
>
>> Sorry if this is documented somewhere but I can’t find it.
>>
>> On desktop platforms, LC gives us “suspend” which is fired when the app goes into the background. I seem to be having some problems with iOS, in that when the screen locks (triggered by  user action or a time limit), my app seems to stop getting messages from the OS, so is in some sense suspended. This seems to call for something like “suspend” for mobiles. Does such a message exist?
>>
>> Another thing that happens with iOS apps that use Location Services is that the user is sometimes asked via a popu-up on the screen of the device whether the app should be allowed to use these services when it’s not running. I don’t know what triggers these user messages, nor am exactly certain what ‘not running’ means - presumably if the app has been properly quit, that’s something other than ‘not running’. In the Standalone Settings for mobile, one can set Location Services as being a requirement, but there doesn’t seem to be a setting corresponding to this user choice.
>>
>> Has anyone a clear understanding of all this? I would love to see an explanation.
>>
>> TIA
>>
>> Graham
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
Thanks to all who replied on this topic - lots of this is new to me! So far, for me the big thing missing is how to **force** iOS to continue sending messages to the app in the background, or alternatively force iOS itself to ask the user the question when the app calls for location data for the first time. Although I have set the ‘experimental’  setting of Location Authorization Type to ‘Always' in my Sstandalone Application Settings, this  does not seem either to ensure access nor to force the message. Maybe wading around in the iOS SDK documentation will help, though somehow I doubt it.

To repeat myself, I have noticed that the following apps which I have used personally, don’t seem to get the OS to ask a question of the user, and yet they unfailingly continue to process the equivalent of locationChanged messages from the GPS when they’re in the background:

Strava
SityTrail
TomTom GO
GB & Parks

and presumably Google Maps and Apple’s own Maps.

They appear to run (i.e execute code, not just sit in RAM) while in the background.I just don’t know how they do it so consistently.

It’s frustrating to try to solve a problem that’s obviously been solved many times before, but just happens not to be in the public domain. I am not sure I will live long enough to come out the other side of all this (I’m including the issue of tracking a route taking into account GPS inaccuracies and anomalies), but if I do, I’ll write it up.

Graham

> On 17 Nov 2020, at 23:39, Mark Smith via use-livecode <[hidden email]> wrote:
>
> And just a reminder that, under iOS, you’ll have to register to receive a “ UIApplicationWillResignActiveNotification” message, and then write a handler to respond to that (PS only register once in your stack script — I learned the hard way). It’s documented under mergNotify in the dictionary (with credit to Elanor for pointing this out to me when my “on shutdownRequest” handlers were being ignored).
>
> Jacque, I believe this is what you are looking for to be notified when you go into the background. I do some db cleanup at that time and it seems to work.
>
> Mark
>
>
>> On Nov 17, 2020, at 6:54 PM, J. Landman Gay via use-livecode <[hidden email]> wrote:
>>
>> Android has always acted like this and now that iOS apps run in the background like Android does, it behaves the same way. At least our problems are cross-platform now.
>>
>> An app will stay in RAM until the user specifically quits or until the OS needs the memory. When that happens, the OS wipes the app and it effectively shuts down. We get no warning, except for a shutDown message. Android recommends we store the last state of the app and restore it when it starts up again.
>>
>> I'd love to get a message when the app goes into the background but so far there is none. Storing every little change as it happens seems tedious and wasteful. I haven't had much luck with storing changes on shutdown but it's worth a try, it's been a while since I did it.
>>
>> --
>> Jacqueline Landman Gay | [hidden email]
>> HyperActive Software | http://www.hyperactivesw.com
>> On November 17, 2020 9:27:50 AM Graham Samuel via use-livecode <[hidden email]> wrote:
>>
>>> Sorry if this is documented somewhere but I can’t find it.
>>>
>>> On desktop platforms, LC gives us “suspend” which is fired when the app goes into the background. I seem to be having some problems with iOS, in that when the screen locks (triggered by  user action or a time limit), my app seems to stop getting messages from the OS, so is in some sense suspended. This seems to call for something like “suspend” for mobiles. Does such a message exist?
>>>
>>> Another thing that happens with iOS apps that use Location Services is that the user is sometimes asked via a popu-up on the screen of the device whether the app should be allowed to use these services when it’s not running. I don’t know what triggers these user messages, nor am exactly certain what ‘not running’ means - presumably if the app has been properly quit, that’s something other than ‘not running’. In the Standalone Settings for mobile, one can set Location Services as being a requirement, but there doesn’t seem to be a setting corresponding to this user choice.
>>>
>>> Has anyone a clear understanding of all this? I would love to see an explanation.
>>>
>>> TIA
>>>
>>> Graham
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
That's good to know. Now all we need is an Android equivalent.

On 11/17/20 4:39 PM, Mark Smith wrote:
> And just a reminder that, under iOS, you’ll have to register to receive a “
> UIApplicationWillResignActiveNotification” message, and then write a handler to respond to that
> (PS only register once in your stack script — I learned the hard way). It’s documented under
> mergNotify in the dictionary (with credit to Elanor for pointing this out to me when my “on
> shutdownRequest” handlers were being ignored).
>
> Jacque, I believe this is what you are looking for to be notified when you go into the
> background. I do some db cleanup at that time and it seems to work.


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Suspend in iOS, or when is a mobile app running?

ELS Prothero via use-livecode
In reply to this post by ELS Prothero via use-livecode
Test

_____________________________________
Sent from http://runtime-revolution.278305.n4.nabble.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode