I had debugged all day and delegate did get called at all.
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
Well here is my standard code calling for a monitor. use CoreLocation.framework.
[locationManager startMonitoringForRegion:geofence];
And registered these in my plist.
<key>NSLocationAlwaysUsageDescription</key>
<string>Lugang</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Lugang</string>
background app refresh in enable, but I didn't see my app within.
I had tried to print my monitoredRegions in instance of LocationManager and there is my monitored region.
NSLog(@"%@" ,locationManager.monitoredRegions);
and regionMonitoringAvailable is true.
NSLog(@"%d" , [CLLocationManager regionMonitoringAvailable] );
In iOS 8, I had asked for requestAlwaysAuthorization
[locationManager requestAlwaysAuthorization];
I had tried three states , app in foreground, app in background, app is not active. none of these states called.
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
didn't get any errors at all.
And I had tried
[locationManager requestStateForRegion:geofence];
works fine.
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
did trigger in my requestStateForRegion.
I don't know what it is to make didEnterRegion didn't get called and I know in iOS 7 and above devices work but I don't have such a device to testify now.
Maybe requestStateForRegion could fulfill my requestment, But I still couldn't figure out how does DidEnterRegion not work. And none of these trigger any error messages to tell developers to debug.
I have face same problem, Following are the steps I was follow and get succeed.
After add your geofence Array data in
locationmanager
. Use below code for the same.Check your start monitoring for region with below delegate.
Use these two delegate method for geofence. 1)
DidEnter
2)DidExit
DidEnter
andDidExit
method so no need to debug. once your method will be call that time local notification is fire.