Author Topic: Running app in background  (Read 5151 times)

sgc.servizi

  • Newbie
  • *
  • Posts: 2
    • View Profile
Running app in background
« on: November 25, 2013, 06:31:58 PM »
Hi everyone, Thank you Kevin for your books: great job! I've an app that need to run a timer, similar on your demo project, in background: on ios6 it works correctly but on ios7 it doesn't works! Can you help me?
Thanks in advance. By by

Danilo

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: Running app in background
« Reply #1 on: November 25, 2013, 09:37:24 PM »
Danilo,

Glad you are enjoying the books!

Check out this link to see if this helps:

http://stackoverflow.com/questions/18901583/start-location-manager-in-ios-7-from-background-task/18962839#18962839

Kevin

sgc.servizi

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Running app in background
« Reply #2 on: December 28, 2013, 07:05:53 PM »
Hi Kevin, merry Christmas (on late, sorry) and happy new year.

I have read your link but I don't understand it, I think that my problem is different.

On ios6 I use this code to run NStimer in background:

Code: [Select]
    UIBackgroundTaskIdentifier bgTask =0;
        UIApplication  *app = [UIApplication sharedApplication];
        bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
            [app endBackgroundTask:bgTask];
        }];
    }
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:Nil repeats:YES];

Unfortunately I don't know how implement this code to use on ios7: have you any ideas?

Danilo