swathy krishnan
swathy krishnan

Reputation: 916

Call a function repeatedly in fixed interval of time in background when the app is not running

My need is to check if the mobile is connected to the same WIFI network repeatedly in 10 seconds interval time when then app is not running.

Can it be coded in the below method :-

- (void)applicationWillResignActive:(UIApplication *)application

And how can it be achieved ??

Upvotes: 1

Views: 280

Answers (2)

drago
drago

Reputation: 1

As Paulw11 already noted, you can't do exactly that. Best what you can do is request a background task which will give you approx. 3 minutes of execution time (iOS 7+) + request notifications about significant location changes [1] which can wake up your app on each cell tower change (this can be combined with background tasks).

For experimental purposes, you might be able to abuse audio player in background to prevent your app from going to suspended state [2]

[1] https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html

[2] http://code.tutsplus.com/tutorials/ios-multitasking-background-audio--mobile-6833

Upvotes: 0

Paulw11
Paulw11

Reputation: 114773

The short answer is you can't - once your app is in the background you have limited execution options as described in the iOS App Programming Guide

Upvotes: 2

Related Questions