carlsednaoui / add-to-calendar-buttons

Easily add a "add to calendar" button to your websites. This JavaScript library supports Google Calendar, iCal, Outlook and Yahoo Calendar.
476 stars 171 forks source link

iCal generated are not displayed on iOS #27

Open lidiotduvillage opened 6 years ago

lidiotduvillage commented 6 years ago

The invite is shown but hidden immediately. It works fine on https://www.addevent.com/ so there must be something broken.

davidlagace commented 6 years ago

@lidiotduvillage The most likely reason for this problem is that your iPhone Calendar is getting synchronized with iCloud or another online calendar service and also that your iPhone is set to sync only the recent most events!

Because the startdate of the event in the exemple is in 2013 your phone doesn't synchronise it! To change it, go to Settings > Calendars > Sync ; here you should be able to see '1 month' as the default setting. You can click on this option to change it to 2 weeks, 1 month, 3 months or 6 months or you can also select All Events for syncing everything in your calendar.

Full details here : https://drfone.wondershare.com/iphone-problems/iphone-calendar-problems.html

lidiotduvillage commented 6 years ago

Thank you for your answer but It's not really helping, I can't ask people using my website to do that. It needs to be fixed in this app.

123HPES321 commented 6 years ago

Try removing the target parameter from the hyperlink.

lidiotduvillage commented 6 years ago

Actually, I noticed that once I click the "add to calendar icon" it open the atc webpage and then ios ask "this website try to show you a calendar invitaion, allows ?"

If I click fast enough (before the webpage is fully loaded) then the invite is properly displayed and stay. But If I wait the end of the loading, then once I validate, the invite is shown and hidden immediately

123HPES321 commented 6 years ago

Same for me. If you remove target entirely you won’t get the prompt and it will just open.

lidiotduvillage commented 6 years ago

Do you mean the <a target="" parameter ? added by atc script ?

julienV commented 6 years ago

@lidiotduvillage see https://github.com/carlsednaoui/add-to-calendar-buttons/pull/28/files#diff-05d0073950a034e1c5a54e507a4d3e54L62

lidiotduvillage commented 6 years ago

Thank you but It does not change anything on my side. The issue occurs on iOS with Safari for instance

damianvila commented 6 years ago

You should replace the target="_blank" on the links with a "download" parameter (just "download", no value). That way, you force the .ics to download and it's shown properly on iOS.

lidiotduvillage commented 6 years ago

thank you a thousand times @damianvila that works perfectly ! you made my day

adynemo commented 6 years ago

Replace target="_blank" by download is a good solution but if you want to Safari (on Apple's device) open automatically the file you can replace https:// by webcal:// on the url of your file. In ouical.js replace

[...]
      var href = encodeURI(
        'data:text/calendar;charset=utf8,' + [
          'BEGIN:VCALENDAR',
          'VERSION:2.0',
          'BEGIN:VEVENT',
          'URL:' + document.URL,
[...] 

by

[...]
      var myURL     = document.URL;
      var myURL     = myURL.replace('https://', 'webcal://');
      var href          = encodeURI(
        'data:text/calendar;charset=utf8,' + [
          'BEGIN:VCALENDAR',
          'VERSION:2.0',
          'BEGIN:VEVENT',
          'URL:' + myURL,
[...] 

With target="_blank" Safari open .ics in iCalendar and with download Safari download .ics and open it.