【问题标题】:ICS file Download fails on iPhone Chrome with "Unknown File Type"ICS 文件下载在 iPhone Chrome 上失败,出现“未知文件类型”
【发布时间】:2013-04-12 13:26:44
【问题描述】:

我有一个 php 脚本,它可以为移动网络应用程序自动生成一个 ics 文件。

在我的 Win7 桌面上使用 Chrome,ics 文件下载正常,并且 Outlook 喜欢它。

在我的 iPhone 上使用 Safari,ics 文件按预期打开日历应用程序,并允许我添加到日历。

在我的 iPhone 上使用 Chrome,我收到“下载失败。Chrome 无法下载此文件。错误 102 ():未知文件类型。”

我正在发送这些标头:

header("Content-Type: text/Calendar; charset=utf-8");
header("Content-Disposition: inline; filename={$slug}.ics");
header("HTTP/1.0 200 OK", true, 200);

我的 ics 文件输出是:

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//example.com//NONSGML blah blah//EN
METHOD:PUBLISH
BEGIN:VEVENT
UID:20130412T062148-527420343@example.com
DTSTAMP:20130412T062148
DTSTART:20130524T134500Z
DTEND:20130524T153000Z
LOCATION:
SUMMARY:This is the summary
DESCRIPTION:This is the description
STATUS:CONFIRMED
TRANS:OPAQUE
END:VEVENT
END:VCALENDAR

对 iPhone Chrome 不喜欢什么有什么想法?

【问题讨论】:

  • 你了解过这个吗?我正在尝试找到解决相同问题的方法。
  • 据我所知,浏览器间的不兼容使得它无法在多个浏览器之间可靠地部署,至少目前是这样。 :(
  • 我有同样的问题,谁能告诉我任何解决方案。
  • 这里有同样的问题。我们有小写的内容类型。 Android 和桌面上的 Chrome 与 iphone 上的 Safari 一样工作正常,但 iPhone 上的 Chrome 却不行。有消息吗?
  • 像 addevent.com 一样在 iOS 中为 Chrome 使用 webcal:// 协议

标签: iphone google-chrome mobile-safari icalendar mobile-chrome


【解决方案1】:

这看起来像是 iOS 版 Chrome 中的一个错误。见https://bugs.chromium.org/p/chromium/issues/detail?id=666211

【讨论】:

    【解决方案2】:

    我看到的大多数例子都是小写的 http://www.w3.org/Protocols/rfc1341/4_Content-Type.html

    试着做那个

    内容类型:文本/日历

    不是

    内容类型:文本/日历

    【讨论】:

    • 我们遇到了同样的问题。我们已经有了小写的内容类型。还有其他想法吗?
    【解决方案3】:

    使用 webcal://your_link.ics

    这应该可以解决您的问题。 Here's a preview of how it'll appear

    这是一个jsbin,演示了用户代理自动选择协议的基础。

    HTML:

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <title>JS Bin</title>
    </head>
    <body>
      <a href="webcal://w3assets.angelbroking.com/wp-content/uploads/2020/07/ANGEL_BROKING_MONSOON_FESTIVAL.ics">Test webcal://</a>
      <br><br>
      <a href="https://w3assets.angelbroking.com/wp-content/uploads/2020/07/ANGEL_BROKING_MONSOON_FESTIVAL.ics">Test https://</a>
      <br><br>
      <a id="auto" href="https://w3assets.angelbroking.com/wp-content/uploads/2020/07/ANGEL_BROKING_MONSOON_FESTIVAL.ics">Auto (check JS)</a>
      <br><br>
      <textarea readonly id="ua"></textarea>
    </body>
    </html>
    

    Javascript:

    // Source: https://stackoverflow.com/a/9039885/3577736
    function is_iOS() {
      return [
        'iPad Simulator',
        'iPhone Simulator',
        'iPod Simulator',
        'iPad',
        'iPhone',
        'iPod'
      ].includes(navigator.platform)
      // iPad on iOS 13 detection
      || (navigator.userAgent.includes("Mac") && "ontouchend" in document)
    }
    
    if(is_iOS()) {
        document.getElementById('auto').href = document.getElementById('auto').href.replace(/https?:/, 'webcal:');
    }
    
    // Debugging
    document.getElementById('ua').value =  navigator.userAgent;
    

    CSS:

    textarea {
      width: 100%
    }
    

    【讨论】:

      猜你喜欢
      • 2014-02-15
      • 2017-09-16
      • 1970-01-01
      • 2014-04-03
      • 2016-10-10
      • 2016-02-14
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      相关资源
      最近更新 更多