2013-03-25 3 views
0

사용자가 특정 위치에 도착/출발 할 때 응용 프로그램을 켜고 끌 수있는 위치 기반 알림을 만들 수있는 기능이있는 응용 프로그램을 만들고 있습니다.iOS 위치 기반 알림

미리 알림은 생성되지만 (첫 번째 그림에 표시된대로) 도착/퇴장시 트리거되지 않습니다. enter image description here

반면에 사용자가 알림을 클릭하면 , 그것은 가지 (사진 번호 2 참조)에 주소를 추가하고 거기에서 나오지 않는 경우 궁금 해서요 enter image description here

트리거에 알림 앱에서 주소 나 다른 제안을 인식하도록 설정하면이 독특한 문제를 해결하는 데 도움이됩니다.

EKReminder *reminder = [EKReminder reminderWithEventStore:_eventStore]; 
reminder.calendar = [_eventStore defaultCalendarForNewReminders]; 

EKStructuredLocation *location; 
NSError *error = nil; 
EKAlarm *alarm = [[EKAlarm alloc]init]; 
reminder.title = @"Turn off Test App"; 
location = [EKStructuredLocation locationWithTitle:self.addressTextField.text]; 
[self.addressTextField resignFirstResponder]; 
alarm.proximity = EKAlarmProximityEnter; 
alarm.structuredLocation = location; 
[reminder addAlarm:alarm]; 

[_eventStore saveReminder:reminder commit:YES error:&error]; 
+0

는 코드를 보여줘! 실제로 알림에 대한 위치 기반 알람을 어떻게 작성하고 있습니까? – matt

+0

코드가 메인 포스트 – rcresnik

답변

3

EKStructuredLocation의 geolocationradius을 설정하지 못하는 것이 문제입니다. 그것이 가지고있는 것은 모두 제목입니다. 그것이 지구상의 어느 곳인지 알려주는 것만으로는 충분하지 않습니다!

예 :

location.geoLocation = 
    [[CLLocation alloc] initWithLatitude:latit longitude:longit]; 
location.radius = 10*1000; // metres 
+0

에 추가되었습니다. 도와 줘서 고마워. – rcresnik

+0

내기. 교훈을 얻었습니다 (희망) : 질문을 할 때 코드를 게시하십시오! – matt

+0

제가 튜토리얼을 진행하고 있었기 때문에 코드가 좋다고 생각했지만이 부분은 포함되지 않았습니다. 이것도 저자에게 알려 드리겠습니다. :) – rcresnik

0

CLLocationManager -startMonitoringForRegion:를 참조하고, CLRegion 클래스 참조 :

사전에

BR, 한국

난이 사용하는 코드를 주셔서 감사합니다.