简体   繁体   English

Safari iOS收藏夹/书签图标未更新apple-touch-icon.png

[英]Safari iOS Favorite/Bookmark icon not updating apple-touch-icon.png

So based on my searches this has been a long-standing bug on iOS/Apple's end. 所以基于我的搜索,这是iOS / Apple端的一个长期存在的错误。 As of yet I haven't been able to confirm a workaround so would like to see if I'm up to speed on this. 到目前为止,我还没有确认一个解决方法,所以我想看看我是否能加快速度。

I incorporated a new favicon on my site with the help of realfavicongenerator, and it's showing up everywhere except Safari iOS where a faulty cache seems to force the old image to show when the site is favorited or bookmarked. 我在realfavicongenerator的帮助下在我的网站上添加了一个新的favicon,除了Safari iOS之外,它出现在任何地方,其中错误的缓存似乎迫使旧图像在网站被收藏或加入书签时显示。 Adding to homescreen works fine, MacOS favoriting/bookmarking works fine, Safari iOS doesn't. 添加到主屏幕工作正常,MacOS收藏/书签工作正常,Safari iOS没有。

I remember having a similar issue when incorporating the first apple-touch-icon a few years ago, also using realfavicongenerator: when favoriting/bookmarking in Safari iOS the icon was empty instead of showing the image. 我记得在几年前使用第一个apple-touch-icon时也有类似的问题,也使用了realfavicongenerator:当在Safari iOS中收藏/书签时,图标为空而不是显示图像。 Eventually it showed up but I don't recall how or exacty when, but it definitely took a lot longer than it should have. 最终它出现了,但我不记得何时或确切时间,但它肯定花了比它应该有更长的时间。

I've obviously tried clearing cache and website data/history through Safari settings, restarting my phone, appending a variable to the apple-touch-icon URL, using both absolute and relative paths, and tinkering with different image size specifications, none of which worked. 我显然已经尝试通过Safari设置清除缓存和网站数据/历史记录,重新启动手机,将变量附加到apple-touch-icon URL,使用绝对路径和相对路径,以及修改不同的图像大小规格,其中没有一个工作。

I saw a suggestion somewhere that resetting the phone may work, but my question in that scenario is what exactly to reset and whether this would compromise other data. 我在某个地方看到了重置电话可能有效的建议,但我在这种情况下的问题是究竟要重置什么,以及这是否会影响其他数据。

Are there any workarounds/fixes I'm not aware of? 有没有我不知道的变通方法/修复方法?

I'm using an iPhone 7 with iOS 12.2. 我正在使用带有iOS 12.2的iPhone 7。 The code being used is straight from what realfavicongenerator provides. 使用的代码直接来自realfavicongenerator提供的代码。

RealFaviconGenerator's author speaking. RealFaviconGenerator的作者发言。

As you noticed, iOS Safari is quite lazy regarding favicon reloading. 正如您所注意到的,iOS Safari对于favicon重新加载非常懒惰。 It is not the only one. 它不是唯一的。

The trick is to force it to reload the icon by providing a URL it never encountered before. 诀窍是通过提供以前从未遇到的URL来强制它重新加载图标。 A simple way of doing this is to suffix the existing icon URL with a dummy parameter. 执行此操作的一种简单方法是使用虚拟参数为现有图标URL添加后缀。 For example, change /the_icon.png to /the_icon.png?v=2 . 例如,将/the_icon.png更改为/the_icon.png?v=2

To do so with RealFaviconGenerator, generate your icons again. 要使用RealFaviconGenerator执行此操作,请再次生成图标。 This time, make sure to open the Version/Refresh tab in the Favicon Generator Options panel, and select the second option, as below: 这次,确保打开Favicon Generator Options面板中的Version / Refresh选项卡,然后选择第二个选项,如下所示:

在此输入图像描述

Note: You might want to edit manually the code already created by RealFaviconGenerator and append the version yourself. 注意:您可能希望手动编辑RealFaviconGenerator已创建的代码并自行附加该版本。 This might be a bad idea. 这可能是一个坏主意。 For example, if you put your icons in your root folder, some HTML lines were not generated (because of conventions RFG is taking advantage of). 例如,如果将图标放在根文件夹中,则不会生成某些HTML行(因为RFG正在利用这些约定)。 But suddenly, these lines must be added to specify a version. 但突然间,必须添加这些行来指定版本。 This is definitely not something you can guess at first sight. 这绝对不是你一见钟情的东西。

New favicon showed up today, with no intervention on my part (versioning had also been removed). 新的favicon今天出现了,我没有干预(版本控制也已被删除)。 Not sure why. 不知道为什么。 Guess it may be due to a time interval. 猜猜可能是由于时间间隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM