It started as a blog about building a mini-ITX server running Linux. Since then I've posted more general articles about computer software, hardware and anything else related. (all spam comments will be removed)

Monday, 10 November 2014

iOS7 Syncing problems with DAViCal

Background

A few years ago I installed DAViCAL on my Linux server and we started sharing our personal calendars. It meant having to install & learn the basics of PostgreSQL but it was worth the pain. The initial setup list (available on the DAViCal home page) was easy to follow, and everything worked first time. There are various clients available that use the CalDAV standard, and we soon had it working nicely on various iPhones, iPads and macbooks using iCal. Everything was great!But then my wife and I upgraded our phones to iOS7, and after a while we became aware that we were no longer seeing each others updates. But as other shared events were still coming through, we knew the calendar server wasn't broken.We weren't the only ones using iOS7, and I'd already installed the DAViCal version with the headers fix, so I knew it should work. The question was, why was it only effecting just these two phones?

Sorting out the Problem

After randomly trying many solutions others had suggested on the web and getting nowhere, I figured the best thing to do was break down the problem and try and debug it logically.- Monitor The Problem -

1. The first thing to do is set up your shared calendar in iCal so that the basic operation of the calendar can be checked.

Add all your accounts into iCal

2. Added an entry and monitor the access.log screen to see what actions are being logged.

3. In terminal (or using Putty if you use windows), connect to your Linux server and type..

You can see here it generated two PUT actions. Watch it for a while and you'll also see things like PROPFIND, OPTIONS, REPORT, and DELETE.4. Once you've got the hang of the sorts of messaging being logged pressed ctrl+c to stop.- Delete iPhone Account Settings -5. Now deleted the problem account from Settings > Mail, Contacts, Calendars on your iPhone.

Delete accounts that aren't syncing.

(WARNING : You will lose any entries that haven't been synced, you may want to move them to the local calendar using the Calendar app first!)6. Open the Calendar app to confirm that all entries on this calendar had gone, and then close it again.- Clear Sync Tokens on the Database -7. Back in terminal, enter the following..

su postgres

psql davical

delete from sync_tokens;

\q

exit

(nb. mine said it deleted 60 rows.)

- Add Accounts to iPhone Again -

8. Go back to Settings on your iPhone and add your account back again (use Other > Add CalDAV Account).

Select 'Other' then Add CalDAV Account.

nb, more details can be found here if you've forgotten how to do it. 9. Restart monitoring of the access.log again in terminal.10. Restart your calendar app and add an entry. As you save, watch the access.log to confirm the phone is writing the event to the server.

Don't expect events to be synced to iCal, or other devices instantly. It can take 5 minutes or more, even after triggering manual updates. The log entries are enough to know your device is syncing with the server.Once you have confirmed your device is now syncing correctly (both from and to iCal) you're ready to do the same on the other phone.

Good luck with fixing your problem, and I hope this works for you too.