If you’re looking for an alternative approach, I built this Add To Calendar Ruby Gem[0] which generates URLs for all the common Calendar platforms. There’s also this reference repo[1] which helps explains how to build your own and lists some other libraries in various languages.
[0] https://github.com/jaredlt/add_to_calendar
[1] https://github.com/InteractionDesignFoundation/add-event-to-...