Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Cree javascript ICS para agregar al calendario en ios

Estoy tratando de obtener este código de esta pregunta ¿ Crear un archivo .ics sobre la marcha usando javascript o jquery? para trabajar sin suerte en un iphone y agregarlo al calendario.

Tengo campos con las horas de inicio y finalización así

 <div class="start-time">9:30am</div> <div class="end-time">10:30am</div> <div class="Location">California</div> <p><a href="#" class="test">Add to Calendar</a></p>

Y mi javascript/jQuery es así

 msgData1 = $('.start-time').text(); msgData2 = $('.end-time').text(); msgData3 = $('.Location').text(); var icsMSG = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Our Company//NONSGML v1.0//EN\nBEGIN:VEVENT\nUID:me@google.com\nDTSTAMP:20120315T170000Z\nATTENDEE;CN=My Self ;RSVP=TRUE:MAILTO:me@gmail.com\nORGANIZER;CN=Me:MAILTO::me@gmail.com\nDTSTART:" + msgData1 +"\nDTEND:" + msgData2 +"\nLOCATION:" + msgData3 + "\nSUMMARY:Our Meeting Office\nEND:VEVENT\nEND:VCALENDAR"; $('.test').click(function(){ window.open( "data:text/calendar;charset=utf8," + escape(icsMSG)); });

También he creado un violín, pero cuando pruebo en un iPhone, abre una nueva ventana y dice que está tratando de agregar un evento de calendario, pero cuando hago clic en Aceptar, dice que no es válido.

https://jsfiddle.net/abennington/ce5xz6y9/10/

Cualquier ayuda sería muy apreciada. :) ¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Considera lo siguiente.

https://jsfiddle.net/Twisty/wmznc6vq/20/

JavaScript

 $(function() { $('.test').click(function(event) { event.preventDefault(); // Format: https://docs.fileformat.com/email/ics/ var icsMSG = "BEGIN:VCALENDAR\nVERSION:2.0\r\n"; icsMSG += "PRODID:-//Our Company//NONSGML v1.0//EN\r\n"; icsMSG += "BEGIN:VEVENT\r\n"; icsMSG += "UID:me@google.com\r\n" icsMSG += "DTSTAMP:20120315T170000Z\r\n"; icsMSG += "ATTENDEE;CN=My Self;RSVP=TRUE:MAILTO:me@gmail.com\r\n"; icsMSG += "ORGANIZER;CN=Me:MAILTO::me@gmail.com\r\n"; icsMSG += "DTSTART:" + $('.start-time').text() + "\r\n"; icsMSG += "DTEND:" + $('.end-time').text() + "\r\n"; icsMSG += "LOCATION:" + $('.Location').text() + "\r\n"; icsMSG += "SUMMARY:Our Meeting Office\r\n"; icsMSG += "END:VEVENT\r\nEND:VCALENDAR"; var title = "newEvent.ics"; var uri = "data:text/calendar;charset=utf8," + escape(icsMSG); var link = $("<a>", { href: uri, download: title, target: "_BLANK" }).html("").appendTo("body"); link.get(0).click(); link.remove(); }); });

Esto se basa en lo siguiente: ¿Cómo cambiar el nombre de los archivos descargados desde window.open() en javascript?

También verificó el formato desde aquí: https://docs.fileformat.com/email/ics/ que sugiere CRLF ( \r\n ).

Más sobre el atributo de descarga: https://caniuse.com/?search=download

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!