문제

IOS5에 추가 된 지리적 인 알림을 사용하는 앱에 대해 생각하고 있습니다 (iOS5에 추가 한 것, 내가 떠나거나 도착할 때 위치를 상기시켜줍니다).그러나이 기능을 사용하고 현재 위치를 사용하여 현재 위치를 가져오고 정의 된 위치와 내 앱으로 정의하고 동일한 LOC인지 여부를 확인해야합니다.현재 및 정의 된 위치가 동일하면 내 앱을 시작하십시오.

이하입니까?

당신이 내 목표를 이해하기를 바랍니다. 미리 감사드립니다

도움이 되었습니까?

해결책

백그라운드에서 위치를 모니터링 할 수있는 동안 앱을 자동으로 시작하지는 않습니다.로컬 알림과 같은 것을 사용하여 사용자에게 앱을 열도록 프롬프트 할 수 있습니다.그러나 배경에서 시작하는 것은 옵션이 아닙니다.적어도 App Store 승인 옵션이 아닙니다.

다른 팁

현재 영역에 대한 검사 및 정의 된 영역은 영역을 모니터링 할 영역을 설정할 때 자동으로 수행됩니다.시작할 수있는 가장 좋은 장소는 CLLocationManagerDelegate, 특히 startMonitoringForRegion:의 문서를 읽는 것입니다.당신이하고 싶은 것은 "지오 펜싱"이라고합니다. 위치 인식을 찾을 수도 있습니다.가이드 .

iPhone 개발에 대한 새로운 기능은 프로그래밍 방식으로 점심 식사를하는 방법을 모르지만 미리 정의 된 위치에 도착하는 방아쇠를 사용하는 데 도움을 줄 수 있습니다.여기 코드가 있습니다.

1 : corelocation.framework 가져 오기

2 : viewController.h 파일의 코드

#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
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top