Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide my app's calendar from built-in calendar app?

My app needs an internal calendar. I can create a new calendar like this:

var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
var cacheCalendar = await store.CreateAppointmentCalendarAsync("unique name here");

This succeeds and I get a new calendar. But this calendar is visible in the phone's built-in calendar app. I don't want this calendar to be visible since it's for internal bookkeeping.

So I try to hide the calendar like this:

var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
var cacheCalendar = await store.CreateAppointmentCalendarAsync("unique name here");
cacheCalendar.IsHidden = true; // <---- make calendar hidden
await cacheCalendar.SaveAsync(); // <---- save; error here

When calling SaveAsyncI get the following exception:

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

Why can't I hide my calendar from the built-in phone calendar app? Is this an undocumented limitation? Are there other ways to do this?

(Note: I tested this on a Windows 10 Mobile as well as desktop Win 10 - same error.)

Edit/Addition: Since Anthony discovered the IsHidden property is documented as read-only in MSDN here is a screenshot from Visual Studio showing the public setter (which makes it compile, run and seemingly legit to call):

IsHidden property has setter

(The app targets Win 10 Build 10586 - maybe it's new, but unfinished?)

like image 536
Heinrich Ulbricht Avatar asked Jul 17 '16 19:07

Heinrich Ulbricht


2 Answers

Honestly I am surprised this even compiles.

According to the MSDN documentation for AppointmentCalandar

IsHidden - Read-only - Gets whether the AppointmentCalendar is hidden in the device's built-in calendar UI

This is a read only property and can't be set.

As for your actual question, after carfully reviewing the documentation it appears that this is an oversight in the API. I would raise this concern on the MSDN forums.

like image 193
Anthony Russell Avatar answered Sep 27 '22 18:09

Anthony Russell


This was a bug in 10586 but if you’re using 14393 SDK you can use IsHidden if your app has rights to the calendar without an InvalidAccessException

https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/15278775-appointmentcalendar-ishidden-setter-throws-a-inval

like image 21
Clint Rutkas Avatar answered Sep 27 '22 17:09

Clint Rutkas