I have to keep a NSThread or NSTimer when my iPhone application goes into background mode. Is it possible ? I have enabled the background modes in info.plist and opened readstream and writestream as follows ...(I am using UDP)
CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType,kCFStreamNetworkServiceTypeVoIP);
CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
But when my application goes to background and locked state, NSThread or NSTimer is not calling . So please suggest me how to achieve background threading in iPhone background locked state ?
I wonder this too.
I want to update my CLLocation (current location) object every five minutes. The only way that i know of is to do this with NSTimer.
What is your advice if this isn't possible?
For some applications(audio, location, voip) Apple allows background execution on supported devices.
Support for some types of background execution must be declared in advance by the application that uses them. An application declares this support by including the UIBackgroundModes
key in its Info.plist
file. Its value is an array that contains one or more strings with the following values:
audio
location
voip
Instead of NSTimer
use UILocalNotification
which can fire notifications both when the app is in the background and in the foreground.