Jailbroken iPhone 3g + startMonitoringSignificantLocationChanges
I was wondering if my code was broken, or if even a jailbroken (multitasking activated) iPhone 3g maybe doesn't support this.
I create a CLLocationManager, set the delegate and so on, and tell it to "startMonitoringSignificantLocationChanges". Whenever the app is then called, I log that to a textView. But nothing ever happens. Not if I drive 5km or 20km.
So I thought, well lets dig a little开发者_运维百科. I found this API: NSLog(@"Location Change Available: %i\n", [CLLocationManager significantLocationChangeMonitoringAvailable]);
Sadly it returns a zero :[
So, what I'm asking is: Did anyone get it to work on a 3g? Any hints? Impossible?
iOS4 brings two new background modes to Core Location: startMonitoringSignificantLocationChanges
and startMonitoringForRegion:desiredAccuracy:
using CLRegion
.
The latter only works on the iPhone 4 device, likely due to new GPS hardware in the device. I confirmed this w/ an Apple rep on the Apple developer forums.
However, I have successfully tested startMonitoringSignificantLocationChanges on a 3GS. I have tested the same code on a jailbroken 3G as well as a vanilla 3G. I believe that simply the answer is that Apple has decided not to enable this feature on the 3G due to lack of resources.
When that feature is enabled, your program will be launched in the background when a significant location event occurs. This background multitasking may stretch the 3G to its limits (in Apple's eyes). Apple's documentation on this subject is VERY unclear about which devices support what. It says "call these methods, and rely on what they return". I've already posted on their developer forums that I wish they would just make it CLEAR which devices support which modes.
Apple's "official" documentation for testing for availability
My blog post documenting how this works on 3GS, iPhone 4
I tried this yesterday, got the same result. I have a jailbroken iPhone 3G running iOS4 with multitasking activated.
[CLLocationManager significantLocationChangeMonitoringAvailable] returns 0
If I use [manager startUpdatingLocation], it does work in the background, but it's using a lot of resources.
精彩评论