OK. I got this to work correctly and experiment with it, and here is the answer. This is what you need to do to get your application to be called when crossing the border of the beacon area after the application has been interrupted (if your application is working correctly in the foreground):
- You must implement the
CLLocation delegate inside your AppDelegate.m module . This delegate is what iOS calls, so if you donโt have the CLLocation delegate CLLocation in AppDelegate.m , you wonโt be able to respond to iOS when your application was interrupted. This is an example of an Apple AirLocate application.
So, inside AppDelegate.m you need the following (you also need to set the CoreLocation.h link):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Inside AppDelegate.m you need to implement the locationManager didDetermineState method, for example:
-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{ UILocalNotification *notification = [[UILocalNotification alloc] init]; if(state == CLRegionStateInside) { notification.alertBody = [NSString stringWithFormat:@"You are inside region %@", region.identifier]; } else if(state == CLRegionStateOutside) { notification.alertBody = [NSString stringWithFormat:@"You are outside region %@", region.identifier]; } else { return; } [[UIApplication sharedApplication] presentLocalNotificationNow:notification]; }
-> So, if your application was interrupted (it should run at least ONCE) when the device goes to the border of the beacon that you control, iOS will call your application and call the locationManager:didDetermineState in your AppDelegate.m module. Inside this method, you can configure and call presentLocalNotificationNow. If your application is NOT in the foreground when this happens, iOS will present a notification on the screen, even if it is locked. Then the user will need to call the application for more information.
I am pretty sure that the memory pressure has nothing to do with it. In addition, setting notifyEntryStateOnDisplay has nothing to do with this problem. The notifyEntryStateOnDisplay setting notifyEntryStateOnDisplay used only when the user turns on the display of the iOS device (ie, falls into the "home" or upper left button). If the user does this, and notifyEntryStateOnDisplay is TRUE , and the INSIDE device is the area of โโthe beacon that you are tracking, THEN you will receive a notification on the display at this time. If this property is set to FALSE , you will not.
Of course, for this material to work correctly, you need to run iOS 7.1.
For more information, visit the Apple documentation
TNBtech Mar 19 '14 at 19:04 2014-03-19 19:04
source share