I am here because I could not find a solution to my problem :(
I am making a simple application in which I have to send (via a socket) some information to the server (e.g. GPS l / L, accuracy, battery level, etc.).
The current code works great when the application is in the foreground.
myTimer = [NSTimer scheduledTimerWithTimeInterval: 2.0 target:self selector: @selector(sendPosToServer:) userInfo:nil repeats: YES]; myTimer2 = [NSTimer scheduledTimerWithTimeInterval: 3.0 target:self selector: @selector(sendBatteryToServer:) userInfo:nil repeats: YES]; myTimer3 = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self selector: @selector(sendResToServer:) userInfo:nil repeats: YES]; myTimer4 = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self selector: @selector(sendQResToServer:) userInfo:nil repeats: YES]; myTimer5 = [NSTimer scheduledTimerWithTimeInterval: 3.0 target:self selector: @selector(sendPrecisionToServer:) userInfo:nil repeats: YES];
All thoses methods are called.
But when the application is entered in the background, all timers are invalid ... I read that iOS automatically stops the timers. I am looking for a way to call methods and send data when the application is in the background.
I need your help:)
Thanks everyone!
ios background scheduling nstimer foreground
user1147981
source share