void Start() { if (CoreXT.IsDevice) { //eventStore, calender, etc will be null if Init() is not called. Manually initilizing helps save memory and must be done before using. PersonalXT.Init(); manager = new CLLocationManager(); //response for calling PersonalXT.RequestCalendarAccess(); //optional handler if you want to add custom messages to the user PersonalXT.CalendarAccess += delegate(object sender, GrantedEventArgs e) { Log("Calendar grant access: " + e.granted); }; //if reminder is granted access, then add reminder as well as retrieve location data PersonalXT.ReminderAccess += delegate(object sender, GrantedEventArgs e) { Log("Reminder grant access: " + e.granted); if (e.granted) { manager.StartUpdatingLocation(); //will update delagate function manager.DidUpdateLocations } }; //removing reminders after it is found. or you can do whatever else with it. PersonalXT.RemindersFound += delegate(object sender, ReminderArgs e) { foreach (EKReminder obj in e.objList) { PersonalXT.eventStore.RemoveReminder(obj, true, null); } Log("Reminders Removed"); }; //alternate way to do call back functions instead of using delegate file (see example PeoplePickerNavigationControllerDelegate.cs) manager.DidUpdateLocations += delegate(object sender, CLLocationManager.DidUpdateLocationsEventArgs e){ manager.StopUpdatingLocation(); EKStructuredLocation location = new EKStructuredLocation(); location.title = "Current location"; location.geoLocation = e.locations[e.locations.Length - 1] as CLLocation; EKReminder reminder = EKReminder.Reminder(PersonalXT.eventStore); reminder.title = "Buy U3DXT at coordinates: " + location.geoLocation.coordinate; reminder.calendar = PersonalXT.eventStore.defaultCalendarForNewReminders; NSError error = null; PersonalXT.eventStore.SaveReminder(reminder, true, error); if (error != null) { Log("error: " + error); } Log("current location coordinates: " + location.geoLocation.coordinate); }; manager.desiredAccuracy = CLLocation.kCLLocationAccuracyNearestTenMeters; manager.distanceFilter = 1; } }
private void GenerarEvento(SalaJuntasReservacionModel Reservaciones) { RequestAccess(EKEntityType.Event, () => { CLLocation location = new CLLocation(); if (Reservaciones.Sucursal_Id == "1") { location = new CLLocation(20.6766, -103.3812); } else { location = new CLLocation(20.6766, -103.3812); } var structuredLocation = new EKStructuredLocation(); structuredLocation.Title = Reservaciones.Sucursal_Domicilio; structuredLocation.GeoLocation = location; NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "dd/MM/yyyy"; NSDate newFormatDate = dateFormat.Parse(Reservaciones.Sala_Fecha); EKEvent newEvent = EKEvent.FromStore(AppHelper.Current.EventStore); DateTime myDate = DateTime.ParseExact(Reservaciones.Sala_Fecha, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); var arrTime = Reservaciones.Sala_Hora_Inicio.Split(':'); var hora = (double.Parse(arrTime[0]) - 1); var minutos = double.Parse(arrTime[1]); var newDate = myDate.AddHours(hora); var newDate2 = newDate.AddMinutes(minutos); var HoraAntesReunion = newDate2; newEvent.AddAlarm(EKAlarm.FromDate(DateTimeToNSDate(HoraAntesReunion.AddMinutes(30)))); newEvent.AddAlarm(EKAlarm.FromDate(DateTimeToNSDate(HoraAntesReunion.AddMinutes(45)))); if (newDate2 != null) { hora = hora + 1; var newDate3 = myDate.AddHours(hora); var newDate4 = newDate3.AddMinutes(minutos); var HoraInicio = this.DateTimeToNSDate(newDate4); newEvent.StartDate = HoraInicio; arrTime = Reservaciones.Sala_Hora_Fin.Split(':'); hora = double.Parse(arrTime[0]); minutos = double.Parse(arrTime[1]); var newDate5 = myDate.AddHours(hora); var newDate6 = newDate5.AddMinutes(minutos); newEvent.EndDate = this.DateTimeToNSDate(newDate6); } newEvent.Title = "Reservación de sala de juntas en " + Reservaciones.Sucursal_Descripcion + ", en el piso " + Reservaciones.Sala_Nivel + ", en la sala " + Reservaciones.Sala_Descripcion; newEvent.Notes = "Se recomienda presentarse 5 minutos antes de su hora de reservación"; newEvent.Calendar = AppHelper.Current.EventStore.DefaultCalendarForNewEvents; newEvent.Location = Reservaciones.Sucursal_Domicilio; newEvent.StructuredLocation = structuredLocation; NSError e; AppHelper.Current.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out e); }); }
public void FromTitle() { if (!TestRuntime.CheckXcodeVersion(4, 5)) { Assert.Inconclusive("EKStructuredLocation is new in 6.0"); } var sl = EKStructuredLocation.FromTitle("my title"); Assert.IsNull(sl.GeoLocation, "GeoLocation"); Assert.AreEqual(0, sl.Radius, "Radius"); Assert.AreEqual("my title", sl.Title, "Title"); }
public void DefaultValues() { if (!TestRuntime.CheckXcodeVersion(4, 5)) { Assert.Inconclusive("EKStructuredLocation is new in 6.0"); } var sl = new EKStructuredLocation(); Assert.IsNull(sl.GeoLocation, "GeoLocation"); Assert.AreEqual(0, sl.Radius, "Radius"); Assert.IsNull(sl.Title, "Title"); }
private void GenerarEvento() { RequestAccess(EKEntityType.Event, () => { CLLocation location = new CLLocation(); if (SucursalModel.Sucursal_Id == "1") { location = new CLLocation(20.6766, -103.3812); } else { location = new CLLocation(20.6766, -103.3812); } var structuredLocation = new EKStructuredLocation(); structuredLocation.Title = SucursalModel.Sucursal_Domicilio; structuredLocation.GeoLocation = location; NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "E, d MMM yyyy HH:mm"; NSDate newFormatDate = dateFormat.Parse(this.FechaReservacion); EKEvent newEvent = EKEvent.FromStore(AppHelper.Current.EventStore); DateTime myDate = ((DateTime)newFormatDate).ToLocalTime(); var HoraAntesReunion = myDate.AddHours(1 * -1); newEvent.AddAlarm(EKAlarm.FromDate(DateTimeToNSDate(HoraAntesReunion.AddMinutes(30)))); newEvent.AddAlarm(EKAlarm.FromDate(DateTimeToNSDate(HoraAntesReunion.AddMinutes(45)))); if (myDate != null) { newEvent.StartDate = DateTimeToNSDate(myDate); newEvent.EndDate = DateTimeToNSDate(myDate.AddHours(1)); } newEvent.Title = "Visita de invitados en " + SucursalModel.Sucursal_Descripcion; newEvent.Notes = "Invitados: "; foreach (UsuarioModel Invitado in InvitadosCalendar) { newEvent.Notes = newEvent.Notes + Invitado.Usuario_Nombre + " " + Invitado.Usuario_Apellidos + ". "; } newEvent.Notes = newEvent.Notes + " Asunto: " + Asunto; newEvent.Calendar = AppHelper.Current.EventStore.DefaultCalendarForNewEvents; newEvent.Location = SucursalModel.Sucursal_Domicilio; newEvent.StructuredLocation = structuredLocation; NSError e; AppHelper.Current.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out e); }); }
void Start() { if (CoreXT.IsDevice) { //eventStore, calender, etc will be null if Init() is not called. Manually initilizing helps save memory and must be done before using. PersonalXT.Init(); manager = new CLLocationManager(); //response for calling PersonalXT.RequestCalendarAccess(); //optional handler if you want to add custom messages to the user PersonalXT.CalendarAccess += delegate(object sender, GrantedEventArgs e) { Log ("Calendar grant access: " + e.granted); }; //if reminder is granted access, then add reminder as well as retrieve location data PersonalXT.ReminderAccess += delegate(object sender, GrantedEventArgs e) { Log ("Reminder grant access: " + e.granted); if(e.granted){ manager.StartUpdatingLocation(); //will update delagate function manager.DidUpdateLocations } }; //removing reminders after it is found. or you can do whatever else with it. PersonalXT.RemindersFound += delegate(object sender, ReminderArgs e) { foreach(EKReminder obj in e.objList){ PersonalXT.eventStore.RemoveReminder(obj, true, null); } Log("Reminders Removed"); }; //alternate way to do call back functions instead of using delegate file (see example PeoplePickerNavigationControllerDelegate.cs) manager.DidUpdateLocations += delegate(object sender, CLLocationManager.DidUpdateLocationsEventArgs e){ manager.StopUpdatingLocation(); EKStructuredLocation location = new EKStructuredLocation(); location.title = "Current location"; location.geoLocation = e.locations[e.locations.Length-1] as CLLocation; EKReminder reminder = EKReminder.Reminder(PersonalXT.eventStore); reminder.title = "Buy U3DXT at coordinates: " + location.geoLocation.coordinate; reminder.calendar = PersonalXT.eventStore.defaultCalendarForNewReminders; NSError error = null; PersonalXT.eventStore.SaveReminder(reminder,true,error); if(error != null) Log ("error: " + error); Log ("current location coordinates: " + location.geoLocation.coordinate); }; manager.desiredAccuracy = CLLocation.kCLLocationAccuracyNearestTenMeters; manager.distanceFilter = 1; } }