views:

42

answers:

3

I've got an iPhone app that's location aware (well, I'd LIKE it to be! ;) but, for some reason, the location notifications never fire.

I'm pretty good with iPhone SDK (30+ yrs dev, iPhone since day-1), and I thought I followed all of the documentation and samples to set everything up correctly. However, when I set it to notify when I enter/leave regions -- say, home and the grocery store -- then go back & forth between the two spots, I don't get the notifications.

I'm sure it's something super-simple that I missed, like "you have to register as a notification-aware app with Apple" (you don't, right?!), but I'm just not seeing what it is.

What are some simple notification-aware-n00b mistakes that can cause the app to just plain not-get-notifications?

Any hints?

While we're at it -- is there a good way to test/debug this stuff in the Sim, say, by injecting "now pretend my location is over HERE" type events? (I know: 2 questions. Hey, they're closely related!)

Thanks!

(Yes, yes -- of course this is all on iOS-4, with the 4.latest SDK...)

A: 

If you're using a non-iPhone4 device, the only time location-aware notifications will fire is when your device skips from one tower to another tower. So if for instance, your home and your grocery store keep you on the same tower, and you never jump to another one, your notifications will never fire.

Protip: Try driving down a highway for a couple tens of kilometers, see what that does. :)

jer
A: 

For example code (referenced earlier) see:

http://developer.apple.com/iphone/library/samplecode/LocateMe/Introduction/Intro.html

as far as the sim goes, no, it won't provide updates. too bad, the android SIM has done it from day 1 (note that this answer is xcode 3.x, I haven't done 4.x yet)

KevinDTimm
A: 

The thing I was missing: regionMonitoringAvailable returns NO on iPhone 3G and 3GS. D'oh!

NOTE: You can sort-of hack around this on 3GS with startMonitoringSignificantLocationChanges, but even that's not available on 3G.

More on that here:

http://longweekendmobile.com/2010/06/30/location-region-data-in-background-on-ios4-iphone/

Olie
The OTHER thing I was missing in my testing: I live out in the sticks, and location-notifications are triggered at cell-tower change. So, even though I was driving well over a mile, as I was on the same cell tower, I was not getting notifications. Once I went into town and got near some towers, things worked better.
Olie