문제

i am making an application which has a feature that allows users to create location based notifications to turn the application on/off when they arrive/leave a certain location.

Reminders are created (as indicated by the first picture), but are not triggered upon arriving/leaving. enter image description here

If on the other hand the user click on the reminder, it kind of adds the address (shown on picture number 2) and is from there on triggered enter image description here

I was wondering if there is a way to make the Reminder app recognize the address or any other suggestion, that might help me in solving this peculiar problem.

Thank you in advance,

BR, Rok

The code that i use is:

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];
도움이 되었습니까?

해결책

The problem is that you are failing to set your EKStructuredLocation's geolocation and radius. All it has is a title. That isn't enough to tell the alarm where on earth it is supposed to be!

Example:

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

다른 팁

See CLLocationManager -startMonitoringForRegion:, and the CLRegion class reference.

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