0

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

Juan M.
  • 146
  • 1
  • 9

3 Answers3

1

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.

nevan king
  • 112,709
  • 45
  • 203
  • 241
  • Although this is useful, what I was asking for was automatically launching of my app. So +1, but the accepted answer is the Bill Burgess answer. Thank you for the info! – Juan M. Jul 28 '12 at 12:26
  • No problem. The way app launching works is that you get a local notification, as Bill says. It's possible that your app will be woken without user interaction, at which time you can do a little work. – nevan king Jul 28 '12 at 13:03
1

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.

Bill Burgess
  • 14,054
  • 6
  • 49
  • 86
0

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
Ravi_Parmar
  • 12,319
  • 3
  • 25
  • 36