TheAlmightyBob / Calendars

Cross-platform calendar API plugin for Xamarin and Windows
MIT License
100 stars 23 forks source link

iOS Calendar is hidden #20

Open schiari opened 8 years ago

schiari commented 8 years ago

When trying to add an event on iOS calendar it's hidden if the calendar is associated to a Microsoft Exchange server. Also from other users I've without Exchange server but with other calendars such as google, etc.. I got the information that calendar of my app was not visible and therefore all the events created from my app were not visible as well

TheAlmightyBob commented 8 years ago

Thank you for the report! Would love some more information about this:

schiari commented 8 years ago

I have iPhone iOS version 9.3.1 Yes I have 0.4.2-beta I can see and reproduce by myself as it's my personal mobile phone With "if the calendar is associated to...", I mean the existing calendar on my mobile phone. If I open the calendar app and I go on calendars I see the calendar from my "Microsoft Exchange email account", then I have a section named "Others" and here I have "My country holidays" (I think it's coming from Apple), "Birthdays", and "Events found in Mail"

I did the same test on my sister's iPhone and it's not working as well. She has other existing calendars, not Microsoft Exchange, I guess she has Google mail account and others, but I don't remember exactly. I can ask if needed.

TheAlmightyBob commented 8 years ago

Interesting. So you don't actually have any iCloud or "local" calendars, it seems (holidays/birthdays are special types... I assume "mail" is also, though I'm not familiar w/ that one). I would be curious if that is also the case for your sister (e.g., only Google accounts). That is not a scenario I've been able to test with (cannot set up the other account types on simulator, and would have to wipe my personal device to get rid of local/iCloud calendars...).

The plugin only really tries to create calendars as iCloud or local. iCloud is preferred because it is known that local calendars will be hidden if it is enabled. Possibly you have found a similar situation, although I'm not too optimistic that it would be possible (or a good idea) to create 3rd-party app calendars on Exchange/Gmail (via iOS). It's theoretically possible that you've actually found a scenario in which iOS does not allow apps to create visible calendars, but I'm not giving up hope yet.

For the moment, I'll probably add some logging to the next version, so more can be learned about where the calendar is being created and why. This seems generally useful.

Of course, you are also welcome to grab the source and debug into it yourself.

TheAlmightyBob commented 8 years ago

New version (0.6.0-beta) is available on NuGet. It will log the available calendar sources (local/iCloud/exchange/etc) along with where it creates the new calendar and why. I would be interested in the results.

schiari commented 8 years ago

I have tried the beta version and following you can see the log result:

2016-05-21 14:00:38.636 FoodFinderiOS[4561:3492071] Sources: 2016-05-21 14:00:38.640 FoodFinderiOS[4561:3492071] Evision, Exchange 2016-05-21 14:00:38.641 FoodFinderiOS[4561:3492071] Subscribed Calendars, Subscribed 2016-05-21 14:00:38.639 FoodFinderiOS[4561:3492071] Default, Local 2016-05-21 14:00:38.642 FoodFinderiOS[4561:3492071] Other, Birthdays 2016-05-21 14:00:38.654 FoodFinderiOS[4561:3492071] Successfully saved calendar with source Default 2016-05-21 14:00:38.657 FoodFinderiOS[4561:3492235] Error getting shared calendar invitations for entity types 3 from daemon: Error Domain=EKCADErrorDomain Code=1014 "(null)"

Adding/Removing and existing event from calendar I always get the following log error meesage:

2016-05-21 14:02:28.700 FoodFinderiOS[4561:3492775] Error getting shared calendar invitations for entity types 3 from daemon: Error Domain=EKCADErrorDomain Code=1014 "(null)"

TheAlmightyBob commented 8 years ago

Hm, thanks. The calendar invitation errors are irrelevant. So this does look like the iCloud situation... except you don't have iCloud. On the one hand I'd be really interested in what would happen if you added a calendar via the iOS Calendar app... but on the other hand I worry that maybe doing so could "fix" it and you wouldn't be able to get back in this state again...

schiari commented 8 years ago

I have an iPad where I had my Exchange account as well and I could replicate the problem. I have deactivated the calendar on my Exchange account and the app it's working fine as I can add and see events on local calendar. Then I have reactivated the Exchange calendar and specified to keep my local calendar. Now I can still add and see events on local calendar created from the App. I guess what did the trick was the question from iOS to keep the existing local calendar when I switched on again the calendar on the Exchange account...

TheAlmightyBob commented 8 years ago

Excellent info, thanks! So now, when you look at the available Calendars in the iOS Calendar app, I assume it shows your calendar under the "Exchange" group? (rather than "Local" or "Subscribed" or "Other" or anything else)

And since you've already taken that step, could you try using "Add Calendar" from the Calendars app and see where that ends up?

If both of those are adding calendars to Exchange, that suggests we should be adding calendars there too...

(the behavior you described thus far is identical to what would happen with iCloud... I just thought iCloud was special)

schiari commented 8 years ago

When I look at the available calendars inside the iOS calendar app I see the calendar created from my app inside the section "On IPAD". The Exchange calendar it's inside another section named "Evision" which is the name of my exchange account. When I create a new event from my app it goes correctly inside the "FoodFinder" calendar which is the one created from the app.

Actually I have "Add Calendar" option in the iOS Calendars app inside both sections: "On IPAD" and on my "Exchange accout".

TheAlmightyBob commented 8 years ago

That is unexpected but promising. I haven't this this "On IPAD" section before... since you were prompted to keep the calendar when re-activating Exchange and it shows up now, I would guess that it was turned into an Exchange calendar... but that theory gets confused by the different sections. And I'm guessing you don't see this calendar if you connect to your Exchange account via other means (e.g. Outlook).

I think I need more logging.

schiari commented 8 years ago

I don't think it's added to the exchange account as on my iPhone I have the same Exchange account and the new calendar is not shown. If you want I can send you screen shots if you give an email address.

TheAlmightyBob commented 8 years ago

I don't think that's necessary right now, your descriptions have been quite clear. I just need to know what the sources for these calendars are, which unfortunately was not included in my last batch of logging. When you were prompted to keep your local calendar, what it was likely doing was converting it from local to something else so that it would show up. If you were to create another new calendar, I'm betting that would once again be hidden initially.

Curious... would you have wanted it to be added to your Exchange account? I'm guessing "no"...

svandelaarschot commented 8 years ago

Investigating this issue aswell trying to fix it.

svandelaarschot commented 8 years ago

See: https://github.com/TheAlmightyBob/Calendars/issues/22

TheAlmightyBob commented 7 years ago

Although this issue has been silent for a year, thought has continued. I've done more research and also spoken to Apple engineers about it (they mostly just confirmed what I'd already found and gave me the impression that Apple has no plans to improve their API anytime soon...).

It would probably be wise to allow specifying an event source rather than just trying to guess at the best one, since aside from the hiding issue it's possible that an app would want to allow the user to choose whether to add a calendar to iCloud or Exchange. Unfortunately that mostly just makes this the caller's problem and doesn't leave them with much better tools to solve it. For example, EventKit doesn't provide the exact name of an account, so you may see two different EKSources simply identified as "Exchange" and not know which to use. EventKit also does not provide a way to know if an EKSource can have calendars added to it other than actually trying to add them.