首页 > 解决方案 > webcal:// 协议 - 在 Chrome iOS 上创建 ical 提醒 - 从提示中隐藏订阅的 URL?

问题描述

我在网站上有一个按钮,可以在点击时添加日历事件。我在大多数浏览器上使用ics.js,但在 iOS 上的 Safari 上使用了不同的解决方案,而在 iOS 上使用 Chrome 浏览器时,我不得不实现 webcal:// 解决方案。

单击时,打开的 URL 是webcal://mysite.com?calreminder=[title]&time=[time]

然后服务器端我们生成这个输出:

function reminder_output()
{
    if (isset($_GET['calreminder'])) {
        $title = $_GET['calreminder'];
        $time = $_GET['time'];

        $now = new DateTime();
        $start = new DateTime('tomorrow ' . $time);
        // event duration is 10 minutes
        $duration = new DateInterval('PT10M');
        $end = $start->add($duration);

        header('Content-Type: text/calendar; charset=utf-8');
        header('Content-Disposition: attachment; filename="My-Site-Reminder.ics"');
        $calData = array(
            'BEGIN:VCALENDAR',
            'PRODID:-//My Site//Reminder//EN',
            'VERSION:2.0',
            'BEGIN:VEVENT',
            'RRULE:FREQ=DAILY;INTERVAL=1',
            'DTSTAMP:' . $now->format('Ymd') . 'T' . $now->format('His'),
            'UID:4088E990AD89VW3DBB4849094',
            'DTSTART:' . $start->format('Ymd') . 'T' . $start->format('His'),
            'DTEND:' . $end->format('Ymd') . 'T' . $end->format('His'),
            'SUMMARY:' . $title,
            'DESCRIPTION:' . $title,
            'X-ALT-DESC;FMTTYPE=text/html:' . $title,
            'END:VEVENT',
            'END:VCALENDAR'
        );
        $calData = implode("\r\n", $calData);
        echo $calData;
        exit;
    }
}

这将打开此提示:

使用 webcal:// 在 iOS 上的 Chrome 中提示

这一切都很好,但理想情况下,我想从显示中隐藏 URL,而是显示事件的名称:“你想订阅 [Event Name] 吗?”

我知道一定可以做到,因为他们在https://www.addevent.com/add-to-calendar-button上做到了:

提示 AddEvent

但是,我不知道如何以这种方式显示它而不是显示 URL。有人知道吗?

标签: icalendarwebcalchrome-ios

解决方案


出现在提示中的日历名称可以通过包括...来设置

X-WR-CALNAME:Your Custom Name

...在 ics 输出的正文中。


推荐阅读