我正在考虑一个应用程序使用地理提醒的应用程序(在ios5中添加的应用程序,在我离开/到达时提醒我。但是我需要使用此功能(实际上,仅使用位置)获取当前位置并将其与我的应用程序的定义位置进行比较,并检查它是否是相同的LOC或它不是。如果当前和定义的位置相同,请启动我的应用程序。

这可能吗?

我希望你能理解我的目标。 提前谢谢

有帮助吗?

解决方案

虽然您将能够从背景中监控您的位置,请记住,它不会自动启动您的应用程序。您可以使用类似本地通知的内容来提示用户打开应用程序。但是从背景开始自动启动不是一个选项。至少不是App Store批准的选项。

其他提示

当您设置要监视的区域时,会自动完成当前区域和定义区域。最佳位置是通过读取生成的文档,尤其是生成的世代odicetagcode。你想做的事情被称为“地理围栏”。您还可以在位置意识中的更多信息指南

作为iPhone开发的新手,我不知道如何以编程方式午餐应用程序,但我可以帮助您解决预定义位置上的触发器。这是代码。

1:导入corelocation.framework

2:在ViewController.h文件下面代码

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

3:veniewcontroller.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
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top