public static void RequestEventStorePermission(EKEntityType entityType, bool assert_granted = false) { TestRuntime.AssertMacSystemVersion(10, 9, throwIfOtherPlatform: false); var status = EKEventStore.GetAuthorizationStatus(entityType); Console.WriteLine("EKEventStore.GetAuthorizationStatus ({1}): {0}", status, entityType); switch (status) { case EKAuthorizationStatus.Authorized: case EKAuthorizationStatus.Restricted: return; case EKAuthorizationStatus.NotDetermined: // There's an instance method on EKEventStore to request permission, // but creating the instance can end up blocking the app showing a permission dialog... // (on Mavericks at least) if (TestRuntime.CheckMacSystemVersion(10, 10)) { return; // Crossing fingers that this won't hang. } NUnit.Framework.Assert.Ignore("This test requires permission to access events, but there's no API to request access without potentially showing dialogs."); break; case EKAuthorizationStatus.Denied: if (assert_granted) { NUnit.Framework.Assert.Ignore("This test requires permission to access events."); } break; } }
public static EKEvent[] FetchEvents(DateTime startDate, DateTime endDate) { // Create the predicate. Pass it the default calendar. //Util.WriteLine ("Getting Calendars"); EKEventStore store = new EKEventStore(); // store.RequestAccess (EKEntityType.Event, (bool granted, NSError e) => { // if (granted) // { //#if DEBUG // Console.WriteLine("Access Granted!"); //#endif // //Do add events calendars and any calendar stuff here // } // else // new UIAlertView ( "Access Denied", "User Denied Access to Calendar Data", null, "ok", null).Show (); // } // ); var calendarArray = store.Calendars; //Util.WriteLine ("Predicate"); //Convert to NSDate NSDate nstartDate = startDate.DateTimeToNSDate(); NSDate nendDate = endDate.DateTimeToNSDate(); NSPredicate predicate = store.PredicateForEvents(nstartDate, nendDate, calendarArray); //Util.WriteLine ("Fetching Events"); // Fetch all events that match the predicate. var eventsArray = store.EventsMatching(predicate); //Util.WriteLine ("Returning results"); if (eventsArray == null) { eventsArray = new List <EKEvent> ().ToArray(); } return(eventsArray); }
public IPhoneUIApplicationDelegate() : base() { #if DEBUG log ("IPhoneUIApplicationDelegate constructor default"); #endif IPhoneServiceLocator.CurrentDelegate = this; #if DEBUG log ("IPhoneUIApplicationDelegate creating event store instance"); #endif eventStore = new EKEventStore ( ); #if DEBUG log ("IPhoneUIApplicationDelegate creating address book instance"); #endif if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) { NSError nsError = new NSError(); addressBook =ABAddressBook.Create(out nsError); #if DEBUG log ("IPhoneUIApplicationDelegate creating address book result: " +((nsError!=null)?nsError.Description:"no error")); #endif } else { addressBook = new ABAddressBook(); } #if DEBUG log ("IPhoneUIApplicationDelegate constructor successfully ended"); #endif }
public void FromEventStore() { EKEventStore store = new EKEventStore(); var c = EKCalendar.FromEventStore(store); // defaults Assert.True(c.AllowsContentModifications, "AllowsContentModifications"); Assert.NotNull(c.CalendarIdentifier, "CalendarIdentifier"); Assert.Null(c.CGColor, "CGColor"); if (TestRuntime.CheckSystemAndSDKVersion(6, 0)) { // default value changed for iOS 6.0 beta 1 Assert.False(c.Immutable, "Immutable"); // new in 6.0 Assert.AreEqual(EKEntityMask.Event, c.AllowedEntityTypes, "AllowedEntityTypes"); } else { Assert.True(c.Immutable, "Immutable"); } Assert.Null(c.Source, "Source"); Assert.False(c.Subscribed, "Subscribed"); Assert.That(c.SupportedEventAvailabilities, Is.EqualTo(EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); Assert.Null(c.Title, "Title"); Assert.That(c.Type, Is.EqualTo(EKCalendarType.Local), "Type"); }
public void Range() { TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 9, throwIfOtherPlatform: false); #if NET using var store = new EKEventStore(); using (var rem = EKReminder.Create(store)) { #else using (var rem = new EKReminder()) { #endif // priority is documented to have a range of 0-9 but there's no validation in ObjC // this test is here to ensure Apple does not start throwing native exceptions at some points rem.Priority = -1; Assert.That(rem.Priority, Is.EqualTo((nint)(-1)), "-1"); rem.Priority = 10; Assert.That(rem.Priority, Is.EqualTo((nint)10), "10"); // The following tests fail randomly. // // at some point values are ?normalized? but no exception is thrown // rem.Priority = nint.MinValue; // Assert.That (rem.Priority, Is.EqualTo ((nint) 0), "MinValue"); // // exposed as an NSInteger but internal storage looks different // rem.Priority = nint.MaxValue; // Assert.That (rem.Priority, Is.EqualTo ((nint) (-1)), "MaxValue"); } } }
void FireEventPermissionCompletionHandler(ClusterEventAuthorizationType eventType) { EKAuthorizationStatus status = EKEventStore.GetAuthorizationStatus(EKEquivalentEventType(eventType)); if (_eventPermissionCompletionHandler != null) { ClusterDialogResult userDialogResult = ClusterDialogResult.Granted; ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted; if (status == EKAuthorizationStatus.NotDetermined) { userDialogResult = ClusterDialogResult.Denied; systemDialogResult = ClusterDialogResult.NoActionTaken; } else if (status == EKAuthorizationStatus.Authorized) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.Granted; } else if (status == EKAuthorizationStatus.Denied) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.Denied; } else if (status == EKAuthorizationStatus.Restricted) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.ParentallyRestricted; } _eventPermissionCompletionHandler((status == EKAuthorizationStatus.Authorized), userDialogResult, systemDialogResult); _eventPermissionCompletionHandler = null; } }
void ICalendar.AddToCalendar(GenEvent genEvent) { var estZone = TimeZoneInfo.FindSystemTimeZoneById("America/Indiana/Indianapolis"); var newStartTime = TimeZoneInfo.ConvertTime(genEvent.StartDateTime, estZone, TimeZoneInfo.Local); var newEndTime = TimeZoneInfo.ConvertTime(genEvent.EndDateTime, estZone, TimeZoneInfo.Local); eventStore = eventStore ?? new EKEventStore(); eventStore.RequestAccess(EKEntityType.Event, (bool granted, NSError e) => { if (granted) { EKEventStore eventStore = new EKEventStore(); //Insert the data into the agenda. EKEvent newEvent = EKEvent.FromStore(eventStore); newEvent.StartDate = CalendarHelpers.DateTimeToNSDate(newStartTime); newEvent.EndDate = CalendarHelpers.DateTimeToNSDate(newEndTime); newEvent.Title = genEvent.Title; newEvent.Notes = genEvent.Location + "\r\n\r\n" + genEvent.Description + "\r\n\r\n" + genEvent.LiveURL ; EKAlarm[] alarmsArray = new EKAlarm[1]; alarmsArray[0] = EKAlarm.FromDate(newEvent.StartDate.AddSeconds(-600)); newEvent.Alarms = alarmsArray; newEvent.Calendar = eventStore.DefaultCalendarForNewEvents; eventStore.SaveEvent(newEvent, EKSpan.ThisEvent, true, out e); Device.BeginInvokeOnMainThread(() => { //bool returned = await GlobalVars.notifier.Notify(ToastNotificationType.Success, // "Event added!", genEvent.Title + " has been added to your calendar!", TimeSpan.FromSeconds(3)); //var returned = await GlobalVars.notifier.Notify(new NotificationOptions() //{ // Title = "Event added!", // Description = genEvent.Title + " has been added to your calendar!", //}); GlobalVars.DoToast(genEvent.Title + " has been added to your calendar!", GlobalVars.ToastType.Green); }); } //do something here else { Device.BeginInvokeOnMainThread(() => { //bool returned = await GlobalVars.notifier.Notify(ToastNotificationType.Error, // "Don't have permission!", "You need to allow this app to access the calendar first. Please change the setting in Settings -> Privacy -> Calendars.", TimeSpan.FromSeconds(4)); //var returned = await GlobalVars.notifier.Notify(new NotificationOptions() //{ // Title = "Don't have permission!", // Description = "You need to allow this app to access the calendar first. Please change the setting in Settings -> Privacy -> Calendars.", //}); GlobalVars.DoToast("Need permission - you need to allow this app to access the calendar first. Please change the setting in Settings -> Privacy -> Calendars.", GlobalVars.ToastType.Red, 5000); }); } }); }
public override void ViewWillAppear (Boolean animated){ base.ViewWillAppear (animated); eventStore = new EKEventStore ( ); requestAccessToRemindersApp (); topicLabel.Text = Booking.Topic; dateLabel.Text = Booking.StartDate.ToShortDateString(); timeLabel.Text = Booking.StartDate.ToShortTimeString() + " - " + Booking.EndDate.ToShortTimeString(); targetGroupLabel.Text = Booking.TargetingGroup; setCampusLabel (); descriptionLabel.Text = Booking.Description; cameraButton.Enabled = !Booking.Attended; if (Booking.Attended) { attendanceLabel.Text = "Attended"; attendanceLabel.TextColor = UIColor.FromRGB (114,179,50); } reminderDatePicker.ValueChanged += (s, e) => { DateTime date = NSDateToDateTime(reminderDatePicker.Date); reminderDateLabel.Text = "Reminder: " + date.ToShortDateString () + " at " + date.ToShortTimeString (); }; reminderSwitch.ValueChanged += delegate { setReminder(); }; cameraButton.Clicked += (sender, e) => { scanQR(); }; }
public void SetReminder(string title) { EventKitUI.EKEventEditViewController eventController = new EventKitUI.EKEventEditViewController(); eventStore = new EKEventStore(); eventStore.RequestAccess(EKEntityType.Reminder, (bool granted, NSError i) => { if (granted) { accessGranted = true; } else { accessGranted = false; } }); eventController.EventStore = eventStore; EKReminder reminder = EKReminder.Create(eventController.EventStore); reminder.Title = title; reminder.Calendar = eventController.EventStore.DefaultCalendarForNewReminders; // save the reminder NSError e; eventController.EventStore.SaveReminder(reminder, true, out e); }
public void Title() { EKEventStore store = new EKEventStore(); var c = EKCalendar.FromEventStore(store); c.Title = "my title"; Assert.That(c.Title, Is.EqualTo("my title"), "Title"); }
/// <summary> /// Initializes the <see cref="U3DXT.iOS.Personal.PersonalXT"/> class. /// </summary> public static void Init() { eventStore = new EKEventStore(); if (GetCalendarAccessStatus() == "Authorized") { calendar = eventStore.defaultCalendarForNewEvents; //for the case where it is already granted } }
public void FromEventStore() { RequestPermission(); EKEventStore store = new EKEventStore(); #if MONOMAC || __MACCATALYST__ var c = EKCalendar.Create(EKEntityType.Event, store); #else var c = EKCalendar.FromEventStore(store); #endif // defaults #if __WATCHOS__ Assert.False(c.AllowsContentModifications, "AllowsContentModifications"); #else Assert.True(c.AllowsContentModifications, "AllowsContentModifications"); #endif Assert.NotNull(c.CalendarIdentifier, "CalendarIdentifier"); #if MONOMAC Assert.Null(c.Color, "Color"); #else Assert.Null(c.CGColor, "CGColor"); #endif if (TestRuntime.CheckXcodeVersion(4, 5)) { // default value changed for iOS 6.0 beta 1 #if __WATCHOS__ Assert.True(c.Immutable, "Immutable"); #else Assert.False(c.Immutable, "Immutable"); #endif // new in 6.0 Assert.AreEqual(EKEntityMask.Event, c.AllowedEntityTypes, "AllowedEntityTypes"); } else { Assert.True(c.Immutable, "Immutable"); } Assert.Null(c.Source, "Source"); Assert.False(c.Subscribed, "Subscribed"); #if MONOMAC || __MACCATALYST__ Assert.That(c.SupportedEventAvailabilities, Is.EqualTo(EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); Assert.That(c.Title, Is.EqualTo(string.Empty), "Title"); #else Assert.That(c.SupportedEventAvailabilities, Is.EqualTo(EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); if (TestRuntime.CheckXcodeVersion(13, 2)) { Assert.That(c.Title, Is.EqualTo(string.Empty), "Title"); } else { Assert.Null(c.Title, "Title"); } #endif Assert.That(c.Type, Is.EqualTo(EKCalendarType.Local), "Type"); }
public void DefaultReminder() { var store = new EKEventStore(EKEntityMask.Reminder); Assert.AreEqual("Reminders", store.DefaultCalendarForNewReminders.Title, "DefaultCalendarForNewReminders"); Assert.IsNull(store.DefaultCalendarForNewEvents, "DefaultCalendarForNewEvents"); Assert.IsNotNull(store.Calendars, "Calendars"); Assert.IsNotNull(store.Sources, "Sources"); }
void ShowActualEventPermissionAlert(ClusterEventAuthorizationType eventType) { EKEventStore aStore = new EKEventStore(); aStore.RequestAccess(EKEquivalentEventType(eventType), delegate { FireEventPermissionCompletionHandler(eventType); }); }
// This is the main entry point of the application. static void Main(string[] args) { // if you want to use a different Application Delegate class from "AppDelegate" // you can specify it here. AppLogger = new Logger(); EventStore = new EKEventStore(); UIApplication.Main(args, null, "AppDelegate"); }
public void GetCalendars() { var store = new EKEventStore(EKEntityMask.Reminder); var calendars = store.GetCalendars(EKEntityType.Reminder); Assert.AreEqual("Reminders", calendars[0].Title, "#1"); calendars = store.GetCalendars(EKEntityType.Event); Assert.AreEqual(0, calendars.Length, "#2"); }
internal static PermissionStatus CheckPermissionStatus(EKEntityType entityType) { var status = EKEventStore.GetAuthorizationStatus(entityType); return(status switch { EKAuthorizationStatus.Authorized => PermissionStatus.Granted, EKAuthorizationStatus.Denied => PermissionStatus.Denied, EKAuthorizationStatus.Restricted => PermissionStatus.Restricted, _ => PermissionStatus.Unknown, });
public void DefaultCalendar() { var store = new EKEventStore(); Assert.AreEqual("Calendar", store.DefaultCalendarForNewEvents.Title, "DefaultCalendarForNewEvents"); Assert.IsNull(store.DefaultCalendarForNewReminders, "DefaultCalendarForNewReminders"); #if !MONOMAC // Not available on Mac Assert.IsNotNull(store.Calendars, "Calendars"); #endif Assert.IsNotNull(store.Sources, "Sources"); }
public void Title() { EKEventStore store = new EKEventStore(); #if MONOMAC var c = EKCalendar.Create(EKEntityType.Event, store); #else var c = EKCalendar.FromEventStore(store); #endif c.Title = "my title"; Assert.That(c.Title, Is.EqualTo("my title"), "Title"); }
public PNVModel () { EventStore = new EKEventStore (); EventStore.RequestAccess(EKEntityType.Event, delegate (bool arg1, NSError arg2) { if (arg2 != null) { Console.WriteLine (arg2.ToString ()); } }); SelectedCalendar = EventStore.DefaultCalendarForNewEvents; }
public void RequestEventStoreAccess(EKEntityType type) { if (eventStore == null) { eventStore = new EKEventStore(); } eventStore.RequestAccess(type, delegate(bool granted, NSError error) { ShowAlert(type == EKEntityType.Event ? DataClass.Calendars : DataClass.Reminders, granted ? "granted" : "denied"); }); }
public void NullableProperties() { #if NET using var store = new EKEventStore(); using (var rem = EKReminder.Create(store)) { #else using (var rem = new EKReminder()) { #endif rem.StartDateComponents = null; rem.DueDateComponents = null; rem.CompletionDate = null; } }
public PNVModel() { EventStore = new EKEventStore(); EventStore.RequestAccess(EKEntityType.Event, delegate(bool arg1, NSError arg2) { if (arg2 != null) { Console.WriteLine(arg2.ToString()); } }); SelectedCalendar = EventStore.DefaultCalendarForNewEvents; }
async Task <PermissionStatus> RequestEventPermission(EKEntityType eventType) { if (GetEventPermissionStatus(eventType) == PermissionStatus.Granted) { return(PermissionStatus.Granted); } eventStore = new EKEventStore(); var results = await eventStore.RequestAccessAsync(eventType).ConfigureAwait(false); return(results.Item1 ? PermissionStatus.Granted : PermissionStatus.Denied); }
public static EKEvent getEvent(CalendarDayEventView theEventView) { EKEventStore store = MyEventStore; var calendarArray = store.Calendars; //Util.WriteLine ("Predicate"); //var newNSDate = (NSDate)theEventView.endDate; //Console.WriteLine ("Date is: {0} {1} {2}", NSDate.Now.ToString (), ((NSDate) DateTime.Now).ToString (), DateTime.Now); NSPredicate predicate = store.PredicateForEvents(theEventView.nsStartDate, theEventView.nsEndDate, calendarArray); //Util.WriteLine ("Fetching Events"); // Fetch all events that match the predicate. return(store.EventsMatching(predicate).Where(x => x.EventIdentifier == theEventView.eventIdentifier).FirstOrDefault()); }
public void AddEvent(string Titulo, string Lugar, DateTime Inicio, DateTime Termina, string Descripcion) { try { EKEventStore evStore = new EKEventStore(); evStore.RequestAccess(EKEntityType.Event, (bool granted, NSError e) => { if (!granted) { new UIAlertView("Acceso denegado", "El usuario no permite acceso al calendario", null, "ok", null).Show(); } }); EKCalendar calendar = evStore.DefaultCalendarForNewEvents; NSPredicate evPredicate = evStore.PredicateForEvents(Inicio, Termina, evStore.GetCalendars(EKEntityType.Event)); bool encontrado = false; evStore.EnumerateEvents(evPredicate, delegate(EKEvent calEvent, ref bool stop) { if (calEvent.Title == Titulo) { encontrado = true; } }); if (encontrado) { new UIAlertView("Evento", "El evento ya existe en el calendario", null, "ok", null).Show(); } else { EKEvent newEvent = EKEvent.FromStore(evStore); newEvent.Title = Titulo; newEvent.Notes = Descripcion; newEvent.Calendar = calendar; newEvent.StartDate = Inicio; newEvent.EndDate = Termina; newEvent.Location = Lugar; var error = new NSError(new NSString(""), 0); evStore.SaveEvent(newEvent, EKSpan.ThisEvent, out error); if (error.LocalizedDescription != "") { new UIAlertView("Evento", "Hubo un problema al agregar el evento " + error.LocalizedDescription, null, "ok", null).Show(); } else { new UIAlertView("Evento", "El evento se agregó a su calendario", null, "ok", null).Show(); } } } catch (Exception) { new UIAlertView("Evento", "Hubo un problema al agregar el evento", null, "ok", null).Show(); } }
public void Title() { RequestPermission(); EKEventStore store = new EKEventStore(); #if MONOMAC || __MACCATALYST__ var c = EKCalendar.Create(EKEntityType.Event, store); #else var c = EKCalendar.FromEventStore(store); #endif c.Title = "my title"; Assert.That(c.Title, Is.EqualTo("my title"), "Title"); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init (); // Code for starting up the Xamarin Test Cloud Agent #if ENABLE_TEST_CLOUD Xamarin.Calabash.Start(); #endif LoadApplication (new App ()); EventStore = new EKEventStore (); return base.FinishedLaunching (app, options); }
public void requestAccess() { eventStore = new EKEventStore(); eventStore.RequestAccess(EKEntityType.Event, (bool granted, NSError e) => { if (granted) { accessGranted = true; } else { accessGranted = false; } }); }
public async Task <bool> AddAppointment(MyAppointmentType appointment) { var eventStore = new EKEventStore(); var granted = await eventStore.RequestAccessAsync(EKEntityType.Event); if (granted.Item1) { EKEvent newEvent = EKEvent.FromStore(eventStore); newEvent.StartDate = DateTimeToNSDate(appointment.ExpireDate); newEvent.EndDate = DateTimeToNSDate(appointment.ExpireDate.AddHours(1)); newEvent.Title = appointment.Title; newEvent.Notes = appointment.WhereWhen; newEvent.Calendar = eventStore.DefaultCalendarForNewEvents; return(eventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out NSError e)); } return(false); }
private async Task RequestCalendarAccess() { if (EKEventStore.GetAuthorizationStatus(EKEntityType.Event) != EKAuthorizationStatus.Authorized) { var accessResult = await _eventStore.RequestAccessAsync(EKEntityType.Event).ConfigureAwait(false); bool hasAccess = accessResult.Item1; NSError error = accessResult.Item2; if (!hasAccess) { // This is the same exception WinPhone would throw throw new UnauthorizedAccessException("Calendar access denied", error != null ? new NSErrorException(error) : null); } } }
public IPhoneUIApplicationDelegate() : base() { #if DEBUG log("IPhoneUIApplicationDelegate constructor default"); #endif IPhoneServiceLocator.CurrentDelegate = this; #if DEBUG log("IPhoneUIApplicationDelegate creating event store instance"); #endif eventStore = new EKEventStore( ); // creating address book instance ReloadAddressBook(); #if DEBUG log("IPhoneUIApplicationDelegate constructor successfully ended"); #endif }
public void CreateService() { if (eventStore == null) { eventStore = new EKEventStore(); bool valueSet = false; eventStore.RequestAccess(EKEntityType.Reminder, (granted, err) => { available = granted; valueSet = true; }); // it's probably bad to busy-wait here, but the permission to use this might // not be quite there yet. Probably better if CreateService was async maybe? while (!valueSet) { } } }
static void FunctionName(EKEventStoreRequestAccessCompletionHandler completion) { if (eventStore) { completion(eventStoreAccessGranted, null); return; } eventStore = EKEventStore.TheNew(); if (eventStore.RespondsToSelector(@selector(requestAccessToEntityType: completion:))) { eventStore.RequestAccessToEntityTypeCompletion(EKEntityTypeEvent, delegate(bool granted, NSError error) { eventStoreAccessGranted = granted; completion(granted, error); }); }
public IPhoneUIApplicationDelegate() : base() { #if DEBUG log ("IPhoneUIApplicationDelegate constructor default"); #endif IPhoneServiceLocator.CurrentDelegate = this; #if DEBUG log ("IPhoneUIApplicationDelegate creating event store instance"); #endif eventStore = new EKEventStore ( ); // creating address book instance ReloadAddressBook (); #if DEBUG log ("IPhoneUIApplicationDelegate constructor successfully ended"); #endif }
public IPhoneUIApplicationDelegate(IntPtr ptr) : base(ptr) { #if DEBUG log ("IPhoneUIApplicationDelegate constructor IntPtr"); #endif IPhoneServiceLocator.CurrentDelegate = this; eventStore = new EKEventStore ( ); if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) { NSError nsError = new NSError(); addressBook =ABAddressBook.Create(out nsError); #if DEBUG log ("IPhoneUIApplicationDelegate creating address book result: " +((nsError!=null)?nsError.Description:"no error")); #endif } else { addressBook = new ABAddressBook(); } }
public void AddEvent(string Titulo, string Lugar, DateTime Inicio, DateTime Termina, string Descripcion) { try { EKEventStore evStore = new EKEventStore(); evStore.RequestAccess(EKEntityType.Event, (bool granted, NSError e) => { if (!granted) new UIAlertView("Acceso denegado", "El usuario no permite acceso al calendario", null, "ok", null).Show(); }); EKCalendar calendar = evStore.DefaultCalendarForNewEvents; NSPredicate evPredicate = evStore.PredicateForEvents(Inicio, Termina, evStore.GetCalendars(EKEntityType.Event)); bool encontrado = false; evStore.EnumerateEvents(evPredicate, delegate(EKEvent calEvent, ref bool stop) { if (calEvent.Title == Titulo) encontrado = true; }); if (encontrado) { new UIAlertView("Evento", "El evento ya existe en el calendario", null, "ok", null).Show(); } else { EKEvent newEvent = EKEvent.FromStore(evStore); newEvent.Title = Titulo; newEvent.Notes = Descripcion; newEvent.Calendar = calendar; newEvent.StartDate = Inicio; newEvent.EndDate = Termina; newEvent.Location = Lugar; var error = new NSError(new NSString(""), 0); evStore.SaveEvent(newEvent, EKSpan.ThisEvent, out error); if(error.LocalizedDescription!="") new UIAlertView("Evento", "Hubo un problema al agregar el evento " + error.LocalizedDescription, null, "ok", null).Show(); else new UIAlertView("Evento", "El evento se agregó a su calendario", null, "ok", null).Show(); } } catch (Exception) { new UIAlertView("Evento", "Hubo un problema al agregar el evento", null, "ok", null).Show(); } }
public void AddEvent (DateTime startDate, DateTime endDate, string title, string location, string description, Action<bool> callback, string id) { EventStore.RequestAccess (EKEntityType.Event, (granted, e) => { if (granted) { eventStore = null; AddEventForReal(startDate, endDate, title, location, description, callback, id); } else { eventStore = null; callback(false); Utils.EnsureInvokedOnMainThread(() => new UIAlertView("Calendar Access Denied", "Oops! Our worker monkeys were unable to add Xamarin Evole. Looks like they need access to your calendar.", null, "OK", null).Show() ); } }); }
public static EKEvent[] FetchEvents(DateTime startDate, DateTime endDate) { // Create the predicate. Pass it the default calendar. //Util.WriteLine ("Getting Calendars"); EKEventStore store = new EKEventStore (); var calendarArray = store.Calendars; //Util.WriteLine ("Predicate"); //Convert to NSDate NSDate nstartDate = Util.DateTimeToNSDate (startDate); NSDate nendDate = Util.DateTimeToNSDate (endDate); NSPredicate predicate = store.PredicateForEvents (nstartDate, nendDate, calendarArray); //Util.WriteLine ("Fetching Events"); // Fetch all events that match the predicate. var eventsArray = store.EventsMatching (predicate); //Util.WriteLine ("Returning results"); if (eventsArray == null) { eventsArray = new List<EKEvent> ().ToArray (); } return eventsArray; }
async Task<PermissionStatus> RequestEventPermission(EKEntityType eventType) { if (GetEventPermissionStatus(eventType) == PermissionStatus.Granted) return PermissionStatus.Granted; if (eventStore == null) eventStore = new EKEventStore(); var results = await eventStore.RequestAccessAsync(eventType).ConfigureAwait(false); return results.Item1 ? PermissionStatus.Granted : PermissionStatus.Denied; }
/// <summary> /// Used for registration with dependency service /// </summary> public static void Init() { eventStore = new EKEventStore(); }
protected EventSingleton() { if (eventStore == null) eventStore = new EKEventStore(); }
/// <summary> /// This method retrieves all the events for the past week via a query and displays them /// on the EventList Screen. /// </summary> protected void GetEventsViaQuery(DateTime startDate, DateTime endDate) { List<CalendarEntry> eventsList = new List<CalendarEntry>(); try { EKEventStore store = new EKEventStore(); EKCalendar calendar = store.DefaultCalendarForNewEvents; // Query the event if (calendar != null) { // Searches for every event in the range of given dates NSPredicate predicate = store.PredicateForEvents(IPhoneUtils.DateTimeToNSDate(startDate),IPhoneUtils.DateTimeToNSDate(endDate),new EKCalendar[] {calendar}); store.EnumerateEvents(predicate, delegate(EKEvent currentEvent, ref bool stop) { // Perform your check for an event type CalendarEntry entry = new CalendarEntry(); entry.Uid = currentEvent.EventIdentifier; entry.Title = currentEvent.Title; entry.Notes = currentEvent.Notes; entry.Location = currentEvent.Location; entry.IsAllDayEvent = currentEvent.AllDay; entry.StartDate = IPhoneUtils.NSDateToDateTime(currentEvent.StartDate); entry.EndDate = IPhoneUtils.NSDateToDateTime(currentEvent.EndDate); try { // TODO: locate how to translate this features // entry.Type (birthday, exchange, etc) //calendarEvent. = entry.IsEditable // Attendees if(currentEvent.Attendees != null && currentEvent.Attendees.Length>0) { int attendeesNum = currentEvent.Attendees.Length; entry.Attendees = new CalendarAttendee[attendeesNum]; int index = 0; foreach(EKParticipant participant in currentEvent.Attendees) { CalendarAttendee attendee = new CalendarAttendee(); attendee.Name = participant.Name; attendee.Address = participant.Url.AbsoluteString; if(participant.ParticipantStatus == EKParticipantStatus.Unknown || participant.ParticipantStatus == EKParticipantStatus.Pending) { attendee.Status = AttendeeStatus.NeedsAction; } entry.Attendees[index] = attendee; index++; } } // Alarms if(currentEvent.HasAlarms && currentEvent.Alarms != null && currentEvent.Alarms.Length >0) { int alarmsNum = currentEvent.Alarms.Length; entry.Alarms = new CalendarAlarm[alarmsNum]; int index = 0; foreach(EKAlarm alarm in currentEvent.Alarms) { CalendarAlarm eventAlarm = new CalendarAlarm(); eventAlarm.Trigger = IPhoneUtils.NSDateToDateTime(alarm.AbsoluteDate); // TODO: how to manage "action", "sound" and "emailaddress" entry.Alarms[index] = eventAlarm; index++; } } // Recurrence Rules (pick only the first one) if(currentEvent.HasRecurrenceRules && currentEvent.RecurrenceRules != null && currentEvent.RecurrenceRules.Length >0) { entry.IsRecurrentEvent = true; EKRecurrenceRule rule = currentEvent.RecurrenceRules[0]; if(rule != null) { entry.Recurrence = new CalendarRecurrence(); if(rule.Frequency == EKRecurrenceFrequency.Weekly) { entry.Recurrence.Type = RecurrenceType.Weekly; } else if(rule.Frequency == EKRecurrenceFrequency.Monthly) { entry.Recurrence.Type = RecurrenceType.Montly; } else if(rule.Frequency == EKRecurrenceFrequency.Yearly) { entry.Recurrence.Type = RecurrenceType.Yearly; } if(rule.RecurrenceEnd != null) { entry.Recurrence.EndDate = IPhoneUtils.NSDateToDateTime(rule.RecurrenceEnd.EndDate); entry.Recurrence.Interval = (int)rule.Interval; entry.RecurrenceNumber = rule.RecurrenceEnd.OccurrenceCount; } } } } catch (Exception ex) { SystemLogger.Log(SystemLogger.Module.PLATFORM, "Unhandled exception while getting calendar entry information (event_id=" + entry.Uid +"). Exception message: " + ex.Message); } eventsList.Add(entry); }); } } catch (Exception ex) { SystemLogger.Log(SystemLogger.Module.PLATFORM, "Unhandled exception while getting calendar entries. Exception message: " + ex.Message); } SystemLogger.Log(SystemLogger.Module.PLATFORM, "eventsList: " + eventsList.Count); UIApplication.SharedApplication.InvokeOnMainThread (delegate { IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Appverse.Pim.onListCalendarEntriesEnd", eventsList); }); }
/// <summary> /// Constructor /// </summary> public CalendarsImplementation() { _eventStore = new EKEventStore(); //iOS stores in negative seconds before the event defaultTimeBefore = -TimeSpan.FromMinutes(15).TotalSeconds; }
private void AddCalendarEvent (object sender, System.EventArgs e) { EKEventStore store = new EKEventStore (); EKCalendar calendar = store.DefaultCalendarForNewEvents; NSError error = null; if (calendar != null) { EKEvent newEvent = EKEvent.FromStore (store); newEvent.Title = "Löwenbräukeller"; newEvent.Calendar = calendar; newEvent.StartDate = _reservation.ReservationTime; newEvent.EndDate = _reservation.ReservationTime.AddMinutes (30); newEvent.Availability = EKEventAvailability.Free; newEvent.Notes = _reservation.Advice; newEvent.Location = "Löwenbräukeller Gastronomie GmbH\n" + "Nymphenburgerstrasse 2\n" + "80335 München"; store.SaveEvent (newEvent, EKSpan.ThisEvent, out error); if (error == null) { var alert = new UIAlertView ( Locale.GetText ("Ihre Reservierung wurde in Ihrem Kalender eingetragen."), "", null, "OK", null); alert.Clicked += delegate { _lblAddCalendarEvent.Text = ""; _btnAddCalendarEvent.RemoveFromSuperview (); }; alert.Show (); } else { using (var alert = new UIAlertView (Locale.GetText("Error"),error.ToString(),null, "OK", null)) { alert.Show (); } } } }
void ShowActualEventPermissionAlert(ClusterEventAuthorizationType eventType) { EKEventStore aStore = new EKEventStore (); aStore.RequestAccess (EKEquivalentEventType (eventType), delegate { FireEventPermissionCompletionHandler (eventType); }); }
protected App() { eventStore = new EKEventStore (); }
/// <summary> /// Initializes the <see cref="U3DXT.iOS.Personal.PersonalXT"/> class. /// </summary> public static void Init() { eventStore = new EKEventStore(); calendar = eventStore.defaultCalendarForNewEvents; }
/// <summary> /// This method retrieves all the events for the past week via a query and displays them /// on the EventList Screen. /// </summary> protected void GetEventsViaQuery(DateTime startDate, DateTime endDate) { List<CalendarEntry> eventsList = new List<CalendarEntry>(); EKEventStore store = new EKEventStore(); EKCalendar calendar = store.DefaultCalendarForNewEvents; // Query the event if (calendar != null) { // Searches for every event in the range of given dates NSPredicate predicate = store.PredicateForEvents(startDate,endDate,new EKCalendar[] {calendar}); store.EnumerateEvents(predicate, delegate(EKEvent currentEvent, ref bool stop) { // Perform your check for an event type CalendarEntry entry = new CalendarEntry(); entry.Uid = currentEvent.EventIdentifier; entry.Title = currentEvent.Title; entry.Notes = currentEvent.Notes; entry.Location = currentEvent.Location; entry.IsAllDayEvent = currentEvent.AllDay; entry.StartDate = currentEvent.StartDate; entry.EndDate = currentEvent.EndDate; // TODO: locate how to translate this features // entry.Type (birthday, exchange, etc) //calendarEvent. = entry.IsEditable // Attendees if(currentEvent.Attendees != null && currentEvent.Attendees.Length>0) { int attendeesNum = currentEvent.Attendees.Length; entry.Attendees = new CalendarAttendee[attendeesNum]; int index = 0; foreach(EKParticipant participant in currentEvent.Attendees) { CalendarAttendee attendee = new CalendarAttendee(); attendee.Name = participant.Name; attendee.Address = participant.Url.AbsoluteString; if(participant.ParticipantStatus == EKParticipantStatus.Unknown || participant.ParticipantStatus == EKParticipantStatus.Pending) { attendee.Status = AttendeeStatus.NeedsAction; } entry.Attendees[index] = attendee; index++; } } // Alarms if(currentEvent.HasAlarms && currentEvent.Alarms != null && currentEvent.Alarms.Length >0) { int alarmsNum = currentEvent.Alarms.Length; entry.Alarms = new CalendarAlarm[alarmsNum]; int index = 0; foreach(EKAlarm alarm in currentEvent.Alarms) { CalendarAlarm eventAlarm = new CalendarAlarm(); eventAlarm.Trigger = alarm.AbsoluteDate; // TODO: how to manage "action", "sound" and "emailaddress" entry.Alarms[index] = eventAlarm; index++; } } // Recurrence Rules (pick only the first one) if(currentEvent.HasRecurrenceRules && currentEvent.RecurrenceRules != null && currentEvent.RecurrenceRules.Length >0) { entry.IsRecurrentEvent = true; EKRecurrenceRule rule = currentEvent.RecurrenceRules[0]; if(rule != null) { entry.Recurrence = new CalendarRecurrence(); if(rule.Frequency == EKRecurrenceFrequency.Weekly) { entry.Recurrence.Type = RecurrenceType.Weekly; } else if(rule.Frequency == EKRecurrenceFrequency.Monthly) { entry.Recurrence.Type = RecurrenceType.Montly; } else if(rule.Frequency == EKRecurrenceFrequency.Yearly) { entry.Recurrence.Type = RecurrenceType.Yearly; } if(rule.RecurrenceEnd != null) { entry.Recurrence.EndDate = rule.RecurrenceEnd.EndDate; entry.Recurrence.Interval = rule.Interval; entry.RecurrenceNumber = rule.RecurrenceEnd.OccurrenceCount; } } } eventsList.Add(entry); }); } // TODO :: this API could no longer be invoked in this way. // the list of entries must be queried after checking access --> so, process has to send data via callback // return eventsList.ToArray(); }
public async Task<bool> addEventToCalendar(Event eve) { eventStore = new EKEventStore(); return await AddAppointment(eve); }
/// <summary> /// Constructor /// </summary> public CalendarsImplementation() { _eventStore = new EKEventStore(); }
/// <summary> /// Initializes the <see cref="U3DXT.iOS.Personal.PersonalXT"/> class. /// </summary> public static void Init() { eventStore = new EKEventStore(); if(GetCalendarAccessStatus() == "Authorized") calendar = eventStore.defaultCalendarForNewEvents; //for the case where it is already granted }
public static EKEvent[] FetchEvents(DateTime startDate, DateTime endDate) { // Create the predicate. Pass it the default calendar. //Util.WriteLine ("Getting Calendars"); EKEventStore store = new EKEventStore (); store.RequestAccess (EKEntityType.Event, (bool granted, NSError e) => { if (granted) { #if DEBUG Console.WriteLine("Access Granted!"); #endif //Do add events calendars and any calendar stuff here } else new UIAlertView ( "Access Denied", "User Denied Access to Calendar Data", null, "ok", null).Show (); } ); var calendarArray = store.Calendars; //Util.WriteLine ("Predicate"); //Convert to NSDate NSDate nstartDate = startDate.DateTimeToNSDate(); NSDate nendDate = endDate.DateTimeToNSDate(); NSPredicate predicate = store.PredicateForEvents (nstartDate, nendDate, calendarArray); //Util.WriteLine ("Fetching Events"); // Fetch all events that match the predicate. var eventsArray = store.EventsMatching (predicate); //Util.WriteLine ("Returning results"); if (eventsArray == null) { eventsArray = new List<EKEvent> ().ToArray (); } return eventsArray; }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method // Profile.EnableUpdatesOnAccessTokenChange (true); // Settings.AppID = appId; // Settings.DisplayName = appName; UserDetails = new UserDetails(); UserProfile = new Profile (); leadsBL = new LeadsBL (); eventStore = new EKEventStore ( ); CalendarList = new List<CalenderEvent> (); customerBL = new CustomerBL (); IsUpdateLeadDone = false; referralRequestBL = new ReferralRequestBL (); CurrentRRList = new List<ReferralRequest> (); userBL = new UserBL (); brokerBL = new BrokerBL (); industryBL = new IndustryBL (); // UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, false); // Code to start the Xamarin Test Cloud Agent #if ENABLE_TEST_CLOUD Xamarin.Calabash.Start(); #endif //return ApplicationDelegate.SharedInstance.FinishedLaunching (application, launchOptions); return true; }
public void RequestEventStoreAccess (EKEntityType type) { if (eventStore == null) eventStore = new EKEventStore (); eventStore.RequestAccess (type, delegate (bool granted, NSError error) { ShowAlert (type == EKEntityType.Event ? DataClass.Calendars : DataClass.Reminders, granted ? "granted" : "denied"); }); }