I've built an API using Django Rest Framework to serve ical feed from my django models. The feed content is validated and works in all calendar applications I've tested except iCal on iOS. iCal on iOs will accept the content if copy/pasted but won't accept to import from url.
I suspect the cause of this problem is the http-header: transfer-encoding: chunked
I'm trying to figure out why the transfer is chunked, and to see if fixing this will allow iOS to read the feed.
Here are some simplified code:
Renderer
from rest_framework import renderers
class ICALRenderer(renderers.BaseRenderer):
media_type = 'text/html'
format = 'ical'
charset = 'utf-8'
def render(self, data, media_type=None, renderer_context=None):
blob = tools.ical_generator(data, 'My calendar name', 'My calendar description')
return blob
tools.ical_generator
def ical_generator(events=[], calname='', caldesc=''):
cal = vobject.iCalendar()
# build header
# iterate over events
# build footer
icalstream = cal.serialize()
return icalstream
note-1: When doing wget, only the header and the footer from the ical_generator will show and the transfer won't complete but "hang" indefinitely.
note-2: the API is also used for other purposes than ical feed, and in other circumstances the http-header is not chunked.
Use Content-type: text/calendar and iCal on iOS will eat it.
text/html and text/plain are allowed by all other validation tools i've tested, so seems iOS is very picky...