Instant Nextcloud calendar updates for Android

My self-hosted Nextcloud instance stores calendars and address books, among other data. On my PCs, Gnome Shell and Thunderbird synchronize them automatically. On Android phones, I use DAVx⁵ for synchronization.

Changes made on the phone are instantly copied to the server, but server-side changes take time: DAVx5 regularly checks if data on the server changed and downloads them to the phone.

I recently learned about UnifiedPush, which provides an open solution this problem, without relying on Google's Firebase Cloud Messaging servers.

UnifiedPush

The push notification setup between an Android application and its (CalDAV, CardDAV, ...) server works like this:

  1. Android app detects that there is a central push notification service installed on the phone (UnifiedPush distributor)
  2. Android app asks the distributor service for an unique push URL
  3. Android app talks with its server and tells it the push URL.

Now that everything is setup, the actual "something changed" event notification is as follows:

  1. Data change on the server. Server software notifies the push URL it got earlier from the Android app.
  2. Distributor service on the phone keeps a permanent connection to the push server and gets instantly notified about the notification
  3. Distributor service sends a notification to the Android app, which wakes up and fetches data from the server.

My setup

UnifiedPush with Conversations

I run my own XMPP instant messaging server: Prosody. My family use Conversations on Android phones that connect to the XMPP server. Conversations already keeps a permanent connection to the server and is ideally suited as push distributor service.

I had to enable mod_unified_push for Prosody and tell Conversations to act as push distributor by selecting my XMPP account to receive push notifications and cweiske.de as push server.

Then I installed the UP-Example app and could send a test notification from the browser to the UP-example app, which was delivered instantly. UnifiedPush itself worked (after I fixed a small bug in mod_unified_push)!

DAV push

To get instant updates for calendars and contacts in address books, Nextcloud needs to notify the push server. It can't do that on its own, but the DAVx5 developers specified the Push for WebDAV protocol extension, built the DAV push app and added support for it in DAVx5.

So at first I installed the DAV push Nextcloud app (1.0.0) on my Nextcloud Hub 10 (31.0.14) instance.

I launched DAVx5 on the phone and selected Conversations as push distributor. Then I selected my account and clicked the red "Refresh list" button. The calendar and address book details now showed "Push Support".

New and modified calendar entries now take mere seconds to be synchronized to the phone - awesome!

Other calendar software

Servers: Apart from Nextcloud with the DAV push app, RustiCal already supports Push for WebDAV. A feature request for Stalwart server is open.

On the client side, there is only DAVx5 for now. I opened a feature request for Thunderbird, which would also benefit from UnifiedPush.

The UnifiedPush apps page lists many applications that support it, mainly instant messaging apps on Android.

Written by Christian Weiske.

Comments? Please send an e-mail.