Question

I am thinking about an app which would use the GEO-reminders (those added in iOS5,Remind me at a Location when I leave/arrive ). But I need using this feature (in fact, only using the location) to get the current location and compare it with the defined location by my app and check whether it's the same loc or it isn't. If the current and defined location are the same, launch my app.

Is this possible?

I hope you to understand my objective. Thanks in advance

Was it helpful?

Solution

While you will be able to monitor your location from the background, keep in mind, it will not automatically launch your app. You can use something like local notifications to prompt the user to open the app. But launching from the background automatically is not an option. At least not an App Store approved option.

OTHER TIPS

The check for current region and defined region are done automatically when you set a region to monitor. The best place to start is by reading the docs for CLLocationManagerDelegate, especially startMonitoringForRegion:. The thing you want to do is called "Geofencing". You can also find more information in the Location Awareness guide.

As 'm new to iPhone Development i don't know how to programmatically lunch an app but i can help you out with the trigger on arriving on predefined location. here is the code.

1: import CoreLocation.framework

2: in viewController.h file place below code

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController<CLLocationManagerDelegate>
@end

3: inviewController.m

#import "ViewController.h"
@interface ViewController (){
CLLocationManager *locationManager;
CLRegion *mexicoBoundary;
}

@end

@implementation ViewController

- (void)viewDidLoad
{
   [super viewDidLoad];

locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];



CLLocationCoordinate2D regionCords ;
//19.432608,-99.133208 lat, lon for mexico city
regionCords=CLLocationCoordinate2DMake(19.432608,-99.133208);
//5000 below, is in meters-radius 
mexicoBoundary =
[[CLRegion alloc]initCircularRegionWithCenter:regionCords
                                       radius:5000.0
                                   identifier:@"mexico_Day"];

[locationManager startMonitoringForRegion:mexicoBoundary];

}

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"%@: %@", @"region entered", region.identifier);

}

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"%@: %@", @"region exited", region.identifier);
}



- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

@end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top