Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

iOS 7 and EKEvent - Adding a EKAlarm is not added to the event

$
0
0

Hi,

I'm trying to create a Calendar event with an alarm from within my iphone app with the code below. I've confirmed that the event gets created in my Calendar, but the problem is the Alarm does not get added in iOS 7.0. It's working fine in iOS 6. E.g. The calendar event and alarm gets added as expected. I hope you can help spot the problem and help me to resolve this?

EKEvent newEvent = EKEvent.FromStore ( App.Current.EventStore );
newEvent.StartDate = DateTime.Now.AddMinutes(10);
newEvent.EndDate = DateTime.Now.AddMinutes(20);
newEvent.Title = "Sample Title";
newEvent.Notes = "Sample note.";
newEvent.Calendar = App.Current.EventStore.DefaultCalendarForNewEvents;
newEvent.Availability = EKEventAvailability.Free;

EKAlarm[] alarmsArray = new EKAlarm[1];
alarmsArray[0] = EKAlarm.FromDate(newEvent.StartDate.AddSeconds(-300));
newEvent.Alarms = alarmsArray;

NSError e;
App.Current.EventStore.SaveEvent ( newEvent, EKSpan.ThisEvent, out e );

I've also tried to add the alarm to the even with the following:

newEvent.StartDate.AddSeconds(-300);

Thanks!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>