简体   繁体   中英

NSTimer or NSThread in iOs 4 background mode

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?

而不是NSTimer使用UILocalNotification ,它可以在应用程序在后台和前台时触发通知。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM