Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to generate an ics file that could add an event on iCalendar #185

Open
amartya-dev opened this issue Jun 16, 2021 · 4 comments
Open

Comments

@amartya-dev
Copy link

I have tested it multiple times, but as soon as I generate an ics file and add an event with it in my iPhone, it almost always fails.

My code:

ics.createEvent(
        {
          title: this.webinarTitle,
          start: [
            date.getFullYear(),
            date.getMonth(),
            date.getDay(),
            date.getHours(),
            date.getMinutes(),
          ],
          duration: { hours: this.webinarDuration },
          organizer: {
            name:
              this.webinarHost.first_name + ' ' + this.webinarHost.last_name,
            email: this.webinarHost.email,
          },
        },
        (error, value) => {
          if (error) {
            console.log(error)
          }
          var filename = `${this.webinarTitle}-invite.ics`
          console.log(value)
          var blob = new Blob([value], {
            type: 'text/calendar;charset=utf8',
            encoding: 'UTF-8',
          })
          console.log(blob.type)
          if (window.navigator.msSaveOrOpenBlob) {
            window.navigator.msSaveBlob(blob, filename)
          } else {
            var elem = window.document.createElement('a')
            elem.href = window.URL.createObjectURL(blob)
            elem.download = filename
            document.body.appendChild(elem)
            elem.click()
            document.body.removeChild(elem)
          }
        }
      )
@ramseth001
Copy link
Contributor

I am also facing this issue

@Jp3rd
Copy link

Jp3rd commented Sep 23, 2021

I have tested it multiple times, but as soon as I generate an ics file and add an event with it in my iPhone, it almost always fails.

My code:

ics.createEvent(
        {
          title: this.webinarTitle,
          start: [
            date.getFullYear(),
            date.getMonth(),
            date.getDay(),
            date.getHours(),
            date.getMinutes(),
          ],
          duration: { hours: this.webinarDuration },
          organizer: {
            name:
              this.webinarHost.first_name + ' ' + this.webinarHost.last_name,
            email: this.webinarHost.email,
          },
        },
        (error, value) => {
          if (error) {
            console.log(error)
          }
          var filename = `${this.webinarTitle}-invite.ics`
          console.log(value)
          var blob = new Blob([value], {
            type: 'text/calendar;charset=utf8',
            encoding: 'UTF-8',
          })
          console.log(blob.type)
          if (window.navigator.msSaveOrOpenBlob) {
            window.navigator.msSaveBlob(blob, filename)
          } else {
            var elem = window.document.createElement('a')
            elem.href = window.URL.createObjectURL(blob)
            elem.download = filename
            document.body.appendChild(elem)
            elem.click()
            document.body.removeChild(elem)
          }
        }
      )

Here is what I did that worked:

const { value } = createEvent(event);
const data = new Blob([value], { type: 'text/calendar' });

do not add UTF-8 as encoding.

@coderdix24
Copy link

coderdix24 commented Nov 30, 2022

I'm placing it in an Uint8Array typed array with a format of 'ics' and its not working. having to do this to upload to cloudinary cdn

@ajainzimyo
Copy link

Anyone to help here. Facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants