xamarin.forms 크로스 플랫폼 C#, XamForms.Controls.Calendar 플러그인을 사용하여 이벤트 추가 및 캘린더 쇼를 사용하여 기기 캘린더에 알림을 설정하지만 이제 알림을 설정하려고합니다. 크로스 플랫폼을 사용하는 xamarin 양식의 perticular 장치 달력xamarin.forms 크로스 플랫폼을 사용하여 기기 캘린더에 미리 알림 설정 C#
4
A
답변
5
DependancyService을 사용해야하고 각 플랫폼에 대한 코드를 작성해야하는 경우 Xamarin.Forms 프로젝트에서 직접 캘린더를 사용하거나 액세스 할 수 없습니다. 참조 용 코드를 첨부합니다.
윈도우 // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn495339.aspx
public async Task AddAppointment(ESF.Core.Models.ESFPortal_Events appointment)
{
var appointmentRcd = new Windows.ApplicationModel.Appointments.Appointment();
var date = appointment.ExpireDate.Value.Date;
var time = appointment.ExpireDate.Value.TimeOfDay;
var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
var startTime = new DateTimeOffset(date.Year, date.Month, date.Day, time.Hours, time.Minutes, 0, timeZoneOffset);
appointmentRcd.StartTime = startTime;
// Subject
appointmentRcd.Subject = appointment.Title;
// Location
appointmentRcd.Location = appointment.WhereWhen;
// Details
appointmentRcd.Details = appointment.Description;
// Duration
appointmentRcd.Duration = TimeSpan.FromHours(1);
// All Day
appointmentRcd.AllDay = false;
//Busy Status
appointmentRcd.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Busy;
// Sensitivity
appointmentRcd.Sensitivity = Windows.ApplicationModel.Appointments.AppointmentSensitivity.Public;
Rect rect = new Rect(new Point(10, 10), new Size(100, 200));
string retVal = await AppointmentManager.ShowAddAppointmentAsync(appointmentRcd, rect, Windows.UI.Popups.Placement.Default);
return !string.IsNullOrEmpty(retVal);
}
안드로이드 // http://developer.xamarin.com/guides/android/user_interface/calendar/ - 또한 IOS // http://developer.xamarin.com/guides/ios/platform_features/introduction_to_event_kit/
변수public async Task<bool> AddAppointment(ESF.Core.Models.ESFPortal_Events appointment)
{
Intent intent = new Intent(Intent.ActionInsert);
intent.PutExtra(CalendarContract.Events.InterfaceConsts.Title, appointment.Title);
intent.PutExtra(CalendarContract.Events.InterfaceConsts.Description, appointment.WhereWhen + " " + appointment.Description);
intent.PutExtra(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(appointment.ExpireDate.Value));
intent.PutExtra(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(appointment.ExpireDate.Value.AddHours(1)));
intent.PutExtra(CalendarContract.ExtraEventBeginTime, GetDateTimeMS(appointment.ExpireDate.Value));
intent.PutExtra(CalendarContract.ExtraEventEndTime , GetDateTimeMS(appointment.ExpireDate.Value.AddHours(1)));
intent.PutExtra(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
intent.PutExtra(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
intent.SetData(CalendarContract.Events.ContentUri);
((Activity)Forms.Context).StartActivity(intent);
return true;
}
의 추가 이해를 위해 안드로이드 문서 도구를 사용
protected EKEventStore eventStore;
public AppointmentServiceh_iOS()
{
eventStore = new EKEventStore();
}
public async Task<bool> AddAppointment(ESF.Core.Models.ESFPortal_Events appointment)
{
var granted = await eventStore.RequestAccessAsync(EKEntityType.Event);//, (bool granted, NSError e) =>
if (granted.Item1)
{
EKEvent newEvent = EKEvent.FromStore(eventStore);
newEvent.StartDate = DateTimeToNSDate(appointment.ExpireDate.Value);
newEvent.EndDate = DateTimeToNSDate(appointment.ExpireDate.Value.AddHours(1));
newEvent.Title = appointment.Title;
newEvent.Notes = appointment.WhereWhen;
newEvent.Calendar = eventStore.DefaultCalendarForNewEvents;
NSError e;
eventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out e);
return true;
}
else
{
new UIAlertView("Access Denied", "User Denied Access to Calendar Data", null, "ok", null).Show();
return false;
}
}
public DateTime NSDateToDateTime(NSDate date)
{
double secs = date.SecondsSinceReferenceDate;
if (secs < -63113904000)
return DateTime.MinValue;
if (secs > 252423993599)
return DateTime.MaxValue;
return (DateTime)date;
}
public NSDate DateTimeToNSDate(DateTime date)
{
if (date.Kind == DateTimeKind.Unspecified)
date = DateTime.SpecifyKind(date, DateTimeKind.Local);
return (NSDate)date;
}
관련 문제
- 1. 캘린더에 알림 추가
- 2. 캘린더에 알림 추가
- 3. 미리 알림 응용 프로그램에 미리 알림 추가
- 4. xamarin의 Android 캘린더에 알림 추가
- 5. 내 알림 미리 알림 관리자를 사용하여
- 6. ASP.NET - Android 기기 용 C# 알림
- 7. Xamarin.Forms Android 용 알림 서비스
- 8. 스위프트 크로스 플랫폼을 사용하여 png 이미지를 작성하는 방법
- 9. Xamarin.Forms DependencyService가 파일 처리시 인터페이스 크로스 플랫폼을 공유 할 수 없습니다.
- 10. gcc를 사용하여 Linux 용 Windows에서 크로스 플랫폼을 컴파일하는 방법은 무엇입니까?
- 11. xamarin.forms 푸시 알림 서버 쪽
- 12. Android 애플리케이션에서 Google 캘린더에 알림 추가
- 13. C#/Xamarin.Forms
- 14. Xamarin.Forms 크로스 플랫폼 프로젝트에서 SQLite 사용하기
- 15. 캘린더에 캘린더 미리 알림을 자동으로 추가하는 이메일
- 16. dijit 캘린더에 미리 정의 된 날짜 전달
- 17. Java 크로스 플랫폼을 통한 iTunes 제어
- 18. 시스템 시간 설정 알림
- 19. 의미 유형을 사용하여 size_t 크로스 플랫폼을 마샬링하는 방법
- 20. 크로스 플랫폼을 사용하여 svg 응용 프로그램을 시작하는 방법은 무엇입니까?
- 21. Electron 크로스 플랫폼을 사용하여 외부 URL에서 검색 결과를 추출 하시겠습니까?
- 22. Xamarin 크로스 플랫폼을 사용하여 Google지도 및지도 핀을 추가하는 방법
- 23. Outlook에서 미리 알림 모임
- 24. 신청자를위한 미리 알림 이메일
- 25. 종료일이없는 미리 알림 설정하기
- 26. 는 미리 알림 시간
- 27. 크로스 플랫폼 이벤트 알림
- 28. 플랫폼을 구별하기 위해 #define을 사용할 방법이 있습니까? (Xamarin.Forms)
- 29. iOS에서 프로그래밍 방식으로 기기 푸시 알림 설정 변경
- 30. 현재 IP 주소 얻기 Xamarin.Forms (크로스 플랫폼)
xamarin potable 클래스 라이브러리에서 사용하는 방법 – sonu
DependencyService –
@ChandreshKhambhayata GetDateTimeMS()를 사용해야한다고 언급 한 적이 있습니다.이 함수에서이 시간에 밀리 초 단위로 시간을 계산하고 있습니까 ?? –