简体   繁体   English

不在主页上时不使用 PWA iPhone 图标

[英]PWA iPhone icon not used when not on the home page

EDIT: I've removed a bunch of the explanation that I had here, because I realized that the issue was intermittent and my previous thoughts were misled.编辑:我删除了我在这里的一堆解释,因为我意识到这个问题是断断续续的,我以前的想法被误导了。

The issue is that the iPhone loads both a screenshot and your web app's icon when downloading your PWA.问题是 iPhone 在下载 PWA 时会同时加载屏幕截图和 web 应用程序的图标。 Whatever loads last gets used as the icon (race condition bug).最后加载的任何内容都用作图标(竞争条件错误)。 My solution was to make the icon file size huge, which causes it to always be loaded last.我的解决方案是使图标文件变大,这导致它总是最后加载。

Here's how I tried setting the icon using Apple's own documentation.以下是我尝试使用 Apple 自己的文档设置图标的方法。 I added this to index.html;我将其添加到 index.html; <link rel="apple-touch-icon" sizes="180x180" href="ream4.png"> Also tried without sizes, because why not; <link rel="apple-touch-icon" sizes="180x180" href="ream4.png">也试过没有尺寸,因为为什么不; <link rel="apple-touch-icon" href="ream4.png">

If anyone wants to compare, this is my manifest.如果有人想比较,这是我的清单。

{
    "name": "Ream",
    "short_name": "Ream",
    "display": "standalone",
    "orientation": "portrait",
    "start_url": "/",
    "icons": [
        {
            "src": "assets/ream6.png",
            "sizes": "64x64 180x180",
            "type": "image/png"
        }
    ],
    "background_color": "#f8f7fa",
    "categories": ["books", "stories", "memberships"],
    "homepage_url": "https://reamstories.com"
}

When I download the app from whatever location, it does download as a PWA and I can use it fine, but the icon is not downloaded unless I create it from the home page of the app.当我从任何位置下载该应用程序时,它确实作为 PWA 下载,我可以很好地使用它,但除非我从应用程序的主页创建它,否则不会下载该图标。 I want the icon to always be used regardless of where the user is and stop using screenshots as icons.我希望无论用户身在何处都始终使用该图标,并停止使用屏幕截图作为图标。

EDIT: More details.编辑:更多细节。 The issue appears to be intermittent.该问题似乎是间歇性的。 Sometimes it uses a screenshot, sometimes it uses the icons.有时它使用屏幕截图,有时它使用图标。 I have no idea why.我不知道为什么。 I tested this by closing the tab and reopening it several times, each time I would try to download the PWA again.我通过关闭选项卡并重新打开几次来对此进行测试,每次我都会尝试再次下载 PWA。 Sometimes it downloads the icon, sometimes it uses a screenshot.有时它会下载图标,有时会使用屏幕截图。 iPhone is just garbage code? iPhone只是垃圾代码?

EDIT ( I think I understand what is happening ): It is in fact intermittent.编辑(我想我明白发生了什么):它实际上是间歇性的。 When the cache is cleared, the icon takes longer to load which causes it display because it loads after the screenshot is generated.清除缓存后,图标需要更长的时间来加载,这会导致它显示,因为它是在生成屏幕截图后加载的。 I think my fix is to make the icon really fng big.我想我的解决办法是让图标真的很大。 So it will always load after the screenshot.所以它总是会在屏幕截图后加载。

This is a bug in Apple's pigsty code.这是 Apple 猪圈代码中的错误。 The only solution is to use a larger image so that the image loads after the screenshot gets taken.唯一的解决方案是使用更大的图像,以便在截取屏幕截图后加载图像。

I solved this by increasing the size of the logo image from 180px to 980px.我通过将徽标图像的大小从 180 像素增加到 980 像素来解决这个问题。 Now it works every time.现在它每次都有效。

I guess this is to be expected from a startup company.我想这对一家初创公司来说是意料之中的。

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

相关问题 从iPhone中的主屏幕图标启动时,方向更改未在PWA中提供适当的窗口高度和宽度 - Orientation change is not giving proper window height and width in PWA when launched from home screen icon in iPhone 在重新启动或第二次添加之前,PWA ICON不会显示在Iphone的主屏幕上 - PWA ICON not showing on home screen of Iphone until restart or second add iPhone主屏幕网页图标 - iPhone home screen web icon 像iPhone的主屏幕图标一样绘制项目 - Draw an Item like home screen icon of iPhone iphone,自动添加主屏幕图标 - iphone, add home screen icon automatically 为我的iPhone主屏幕设置网站的图标 - set icon for my website for iphone home screen 首次访问Web应用程序时,直接将“剪辑”图标添加到iPhone的主屏幕 - Directly add Clip icon to Home Screen of an iphone when webapp is first accessed iPhone“主”屏幕上使用的UIView的名称是什么? - What is the name of the UIView used at the “home” screen of iPhone? 当使用url参数时,iphone的Webapp从主屏幕切换到Safari - Webapp for iphone switches from home screen to Safari when url parameters are used 在网站上添加特定页面的书签,而不考虑添加到主屏幕时iPhone上的哪个页面? - Bookmark certain page on site regardless of what page your on for iPhone when adding to home screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM