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

calendar event not getting created programmatically

$
0
0

I am trying to add a new event to ios calendar but i cant do it programmatically. Here is the code that i am using,
`EKEvent newEvent = EKEvent.FromStore (App.Current.EventStore);
// set the alarm for 5 minutes from now
//newEvent.AddAlarm (EKAlarm.FromDate (DateTime.Now.AddMinutes (5)));
// make the event start 10 minutes from now and last 30 minutes
newEvent.StartDate = DateTime.Now.AddMinutes (10);
newEvent.EndDate = DateTime.Now.AddMinutes (40);
newEvent.Title = "Appt. to do something Awesome!";
newEvent.Notes = "Find a boulder, climb it. Find a river, swim it. Find an ocean, dive it.";
newEvent.Calendar = App.Current.EventStore.DefaultCalendarForNewEvents;

        // save the event
        NSError e;
        App.Current.EventStore.SaveEvent (newEvent, EKSpan.ThisEvent, out e);
        if (e != null) {
            new UIAlertView ("Err Saving Event", e.ToString (), null, "ok", null).Show ();
            return;
        } else {
            new UIAlertView ("Event Saved", "Event ID: " + newEvent.EventIdentifier, null, "ok", null).Show ();
            Console.WriteLine ("Event Saved, ID: " + newEvent.EventIdentifier);
        }

        // to retrieve the event you can call
        EKEvent mySavedEvent = App.Current.EventStore.EventFromIdentifier ( newEvent.EventIdentifier );
        Console.WriteLine ("Retrieved Saved Event: " + mySavedEvent.Title);`

I really need to do this asap. any help will be appreciated.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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