Running in background (iOS)

Previous topic - Next topic

msx

Is it possible to get my app running in the background? It is an app that alerts you of speed cameras and it would be very important that it work in the background to use it together with a GPS navigator.  :-[

spacefractal

#1
No, glbasic was never designed for that. It's can crash very very easy on both android and iOS versions. So HIBERNATE must been used.

So hence I'm forced to turn AUTOPLAY to true always.

Same will been happens in Android version to prevent crashes in a future update as well.

Glbasic was not designed for this kind of apps, it's a game language.

However I'm do could call a SUB, while it's in under that command (if its exist) in a update......
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

I found this.

Code (glbasic) Select
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    UIApplication *app = [UIApplication sharedApplication];

    //create new uiBackgroundTask
    __block UIBackgroundTaskIdentifier bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    }];

    //and create new timer with async call:
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //run function methodRunAfterBackground
        NSTimer* t = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(methodRunAfterBackground) userInfo:nil repeats:NO];
        [[NSRunLoop currentRunLoop] addTimer:t forMode:NSDefaultRunLoopMode];
        [[NSRunLoop currentRunLoop] run];
    });
}


Is it possible to call GLB_ON_LOOP inside dispatch_async?

spacefractal

im will not recommend to do that and its might simply crash out instead. Im have various crash issues, when its called while its in background.....

So its must being in the HIBERNATE issue to prevent eventuelly crashes. here have been many various issues about that, so im d ont recommend that (since iOS4 me thinks). Im will also do that on Android as well, since im believe all crashes is due the same reason (example when a ads is called).

So im need to take a look on HIBERNATE again to checkout its also doing that correctly on Android too.

When that is fixed, im will add a call in the command to call GLB_ON_HIDE, if the sub exists (for all platforms).....

PS. Im should also check the SOCK commands also fails on Android (which the source code im have, which mightbeen a little bit old, or other fails, or its a iOS exclusive issue). Sadly im are not expert on that area at all.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

Thanks spacefractal.

P.D.: SOCK works perfectly on Android.

spacefractal

im might have a different (and eventuelly a bit older code) source code as you have, which >might< bork on Android as well. Hence im will make sure its not that case. Im will today send all fixes to Gernot as well.

In next version, HIBERNATE will also call GLB_ON_HIDE each 0.5 secs while idle in the command (if the sub exists of course). IM also send that fix to Gernot as well.

Then Gernot need to send me back all code again after that, so we make sure we in sync.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx