1

앱 알림과 같은 위치 정보 알림을 구현하고 싶습니다.알림과 같은 로컬 알림이있는 Geolocation

앱 위임에 :

CLLocationCoordinate2D location2D = mapView.region.center; 
CLRegion *regionForMonitoring = [[CLRegion alloc] initCircularRegionWithCenter:location2D radius:1 identifier:@"RegionIdentifier"]; 
[[Utils getLocationManager] startMonitoringForRegion:regionForMonitoring]; 

은 이제 더 있습니다

self.locationManager = [[[CLLocationManager alloc] init] autorelease]; /* don't leak memeory! */ 
[self.locationManager setDelegate:self]; 
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; 

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region 
{ 

} 

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region 
{ 

} 

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{ 

} 

그리고 뷰 컨트롤러 마녀이 하나가 모니터링을 시작 이 이미 한 일이다 이 정보로 지역 알림을 시작하려면 어떻게해야하는지 생각해보십시오.

답변

5

반경이 너무 작아서 업데이트를 실제로 트리거 할 수 없을 가능성이 높습니다. 반지름을 1 미터로 설정했습니다. 즉, 테스트 이외에서 등록 거의 너무 정확한 위치 업데이트를 걸릴 것입니다 것은 당신이 전달 조정합니다.

당신이 지역 이벤트를 얻을 가정, 나는 -didEnterRegion 또는 -didExitRegion 방법에서 지역 알림을 둘 것입니다. @Missaq가 말한 것처럼 알림을 만들 수 있습니다.

UILocalNotification *notification = [[UILocalNotification alloc] init]; 
notification.fireDate = [NSDate date]; 
NSTimeZone* timezone = [NSTimeZone defaultTimeZone]; 
notification.timeZone = timezone; 
notification.alertBody = @"Notification message"; 
notification.alertAction = @"Show"; 
notification.soundName = UILocalNotificationDefaultSoundName; 
[[UIApplication sharedApplication] scheduleLocalNotification:notification]; 
[notification release]; // release if not using ARC 

애플리케이션이 활성화되어있는 경우 알림을받지 않습니다. 신고서를보고 싶다면 배경 모드 여야합니다. 신청서가 활성화 된 경우 UILocalNotification 대신 UIAlertView을 제출해야합니다. 희망이 도움이됩니다.

+0

예, 그게 ... 1 미터가 문제였습니다 !! 고마워!! – Missaq

+0

좋아요! 기꺼이 도와주세요. 받아 줘서 고마워. –

+0

나는 그 주제를 파고있다. 이 방법을 사용하면 응용 프로그램이 깨어있는 경우에만 메소드'didEnterRegion'이 트리거됩니다. 응용 프로그램이 실행되지 않아도 지역화 된 알림을받을 수 있습니까? –

2

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region; 

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region; 

위임 방법을 사용하십시오.

+0

이 방법에서해야 할 일은 무엇입니까? – Missaq

+0

잘 로컬 알림을 만드시겠습니까? –

+0

이렇게 :'- (void) locationManager : (CLLocationManager *) manager didEnterRegion : (CLRegion *) region { UILocalNotification * notif = [[UILocalNotification alloc] init]; notif.fireDate = [NSDate date]; NSTimeZone * tz = [NSTimeZone defaultTimeZone]; notif.timeZone = tz; notif.alertBody = @ "입력 한 지역"; notif.alertAction = @ "표시"; notif.soundName = UILocalNotificationDefaultSoundName; [[UIApplication sharedApplication] scheduleLocalNotification : notif]; }' – Missaq

관련 문제