IOS Geofencing background alert
ios
Solution
Check the "testing your apps region monitoring" section in
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html
If you switch back and forth between foreground and background the threshold conditions might not be met and trigger before you bring the app to the foreground again.
Also when the backgrounded app gets a notification there is only a small window for processing the message. Trying to do network requests might time out...
Check your plist settings - declare location as UIBackgroundModes only required if you need high precision positioning. The significant location changes works even without location defined.
Check that locationManager:didUpdateLocations: and locationManager:didFailWithError: are being called and no errors are posted.
Check that you haven't set ApplicationRunsInBackground to NO in your plist.
Try implementing the AppDelegates applicationDidEnterBackground:, application:didFinishLaunchingWithOptions: and friends to spot where in the app lifecycle you are at a given time.
Problem
I'm working on an app that alerts the user when he is close to some landmarks using the region monitoring. Everything works fine but when the app is in the background I don't get the alerts. When I open the app I get all the alerts popping up. What I wanted was to get them when the app is in the background. I'm wondering if it's possible or does the app needs to be running to get alerts? Any help would be greatly appreciated. Update: The problem seems to be that I used Alerts instead of local notifications. Here's the code I used: ``` - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"Entered Region - %@", region.identifier); [self showRegionAlert:@"You are near: " forRegion:region.identifier]; } ``` How can I change this to local notifications?