数据:URI的iCal中没有Android或iPhone上运行数据、URI、iCal、Android

2023-09-06 10:50:03 作者:我有我的装逼梦

我试图创建一个使用数据使用iCal的移动设备上的日历项://计算器:如 HTTP描述乌里.COM / A /90236分之4551467。现在,我的台式机上的伟大工程,当我在浏览器中运行这一点,我的日历应用程序是微软的Outlook。

基本上,我在Javascript中做的是:

  VAR icalsample =BEGIN:VCALENDAR \\ r \\ n \\版本:2.0 \\ r \\ n \\PRODID: -  \\ / \\ / mycompany.com \\ / myProduct的\\ / \\ / NONSGML V1.0 \\ / \\ / EN \\ r \\ n \\BEGIN:VEVENT \\ r \\ n \\UID:+ UUID +@ mycompany.com \\ r \\ n \\DTSTAMP:+ dtstamp.toISOString()+\\ r \\ n \\主办单位; CN = myCompany中调度\\ r \\ n \\DTSTART:+ dtstart.toISOString()+\\ r \\ n \\DTEND:+ dtend.toISOString()+\\ r \\ n \\摘要:+标题+\\ r \\ n \\描述:+说明+\\ r \\ n \\END:VEVENT \\ r \\ n \\END:VCALENDAR \\ r \\ n;VAR uriContent =数据:文本/日历,+ EN codeURIComponent(icalsample);location.href = uriContent; 

这是我的应用程序的一个例子uriContent如下。当我把它复制并粘贴到浏览器的地址栏中它按预期工作:

data:text/calendar,BEGIN%3AVCALENDAR%0AVERSION%3A2.0%0APRODID%3A-%2F%2Fmycompany.com%2Fmyproduct%2F%2FNONSGML%20v1.0%2F%2FEN%0ABEGIN%3AVEVENT%0AUID%3A3e40a5db-bfe3-4ab5-92c0-22cb7aeaa2d4%40mycompany.com%0ADTSTAMP%3A2013-03-15T18%3A17%3A55.792Z%0AORGANIZER%3BCN%3Dmycompany%20scheduler%0ADTSTART%3A2013-03-18T16%3A00%3A00.000Z%0ADTEND%3A2013-03-18T20%3A00%3A00.000Z%0ASUMMARY%3AService%20Appointment%0ADESCRIPTION%3Aupgrade.%0AEND%3AVEVENT%0AEND%3AVCALENDAR

我的问题是它不能在iPhone或Android工作。从我读过,我想数据:尤里斯的支持。

iPhone 7成功运行Android 10

在使用默认的浏览器(Chrome的不)的Andr​​oid 4.1.1,我看到我的字符串的文本显示像在浏览器中一个纯文本文档。在iPhone上我看到下载失败:Safari无法下载此文件。

我怎样才能让iPhone和Android上这项工作?

更新---

有在上面的原code一些一些错误。所有线路必须在\\ r \\ n结束。我只有\\ n。最后一行还需要\\ r \\ n。 JavaScript的Date.toISOString格式无效的iCal。你必须删除破折号,分号和第二的分数。捕捉这些错误的一个非常有价值的工具是的iCal验证。

更重要的是,我不认为Android支持iCal或ICS文件。有很多的论坛帖子讨论这个和第三方工具填补这一空白。所以我觉得我的code是正确的(除了在更新上面列出的错误),但它失败了我的手机,因为没有应用程序或意向登记文本/日历MIME类型。

解决方案

我有同样的问题 - 直到我发现这个线索,我不能拿到iPhone阅读我的iCal文件

Safari浏览器会说Safari无法下载此文件,这是一种误导 - Safari浏览器下载了 - 但它的文件并没有像标准的ISO格式的日期,用连字符和冒号

解决的办法,你说得对,它是:

请确保该行结束CRLF。确保上面有没有空行BEGIN:VCALENDAR确保日期格式为ISO - 但有删除破折号和分号

感谢您的指向正确的方向!

I'm attempting to create a calendar entry using ical on a mobile device using data:Uri as described in http://stackoverflow.com/a/4551467/90236. Now it works great on my desktop machine when I run this in Chrome and my calendar app is MS Outlook.

Basically, what I do in Javascript is:

var icalsample = "BEGIN:VCALENDAR\r\n\
VERSION:2.0\r\n\
PRODID:-\/\/mycompany.com\/myproduct\/\/NONSGML v1.0\/\/EN\r\n\
BEGIN:VEVENT\r\n\
UID:" + uuid + "@mycompany.com\r\n\
DTSTAMP:" + dtstamp.toISOString() + "\r\n\
ORGANIZER;CN=mycompany scheduler\r\n\
DTSTART:" + dtstart.toISOString() + "\r\n\
DTEND:" + dtend.toISOString() + "\r\n\
SUMMARY:" + title + "\r\n\
DESCRIPTION:" + description + "\r\n\
END:VEVENT\r\n\
END:VCALENDAR\r\n";

var uriContent = "data:text/calendar," + encodeURIComponent(icalsample);
location.href = uriContent;

An example uriContent from my app is below. When I copy and paste it into Chrome's address bar it works as expected:

data:text/calendar,BEGIN%3AVCALENDAR%0AVERSION%3A2.0%0APRODID%3A-%2F%2Fmycompany.com%2Fmyproduct%2F%2FNONSGML%20v1.0%2F%2FEN%0ABEGIN%3AVEVENT%0AUID%3A3e40a5db-bfe3-4ab5-92c0-22cb7aeaa2d4%40mycompany.com%0ADTSTAMP%3A2013-03-15T18%3A17%3A55.792Z%0AORGANIZER%3BCN%3Dmycompany%20scheduler%0ADTSTART%3A2013-03-18T16%3A00%3A00.000Z%0ADTEND%3A2013-03-18T20%3A00%3A00.000Z%0ASUMMARY%3AService%20Appointment%0ADESCRIPTION%3Aupgrade.%0AEND%3AVEVENT%0AEND%3AVCALENDAR

My problem is it does not work on iPhone or Android. From what I had read, I thought data:Uris were supported.

On Android 4.1.1 using the default browser (not Chrome), I see the text of my string displayed like a plain text document in the browser. On iPhone I see "Download Failed: Safari cannot download this file".

How can I make this work on iPhone and Android?

Update---

There some some errors in the original code above. All lines must end in \r\n. I had only \n. The last line also requires \r\n. The javascript Date.toISOString format is not valid for iCal. You have to remove the dashes, semicolons, and fractions of a second. A really valuable tool for catching these errors is the ical validator.

Most importantly, I don't think Android supports iCal or ics files. There are lots of forums posts discussing this and 3rd party tools to fill this gap. So I think my code was correct (apart from the bugs listed above in the update), but it failed on my phone because not app or Intent is registered for the text/calendar mime type.

解决方案

I had the same problem - and until I found this thread, I couldn't get the iPhone to read my iCal file.

Safari would say "Safari cannot download this file" which is misleading - Safari had downloaded the file -but it didn't like the standard ISO format date, with dashes and colons.

The solution, as you rightly put it is:

Make sure the line endings are CRLF. Make sure there is no empty lines above BEGIN:VCALENDAR Make sure the date format is ISO - but has dashes and semi-colons removed.

Thanks for pointing in the right direction!