0

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];
rcresnik
  • 120
  • 9

2 Answers2

3

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
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • You bet. Lesson learned (I hope): when you ask a question, post your code! – matt Mar 26 '13 at 20:25
  • i thought the code was good, since i was working through a tutorial, but it did not include this part. Will notify the author of this as well... :) – rcresnik Mar 27 '13 at 08:36
0

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

Hal Mueller
  • 7,019
  • 2
  • 24
  • 42