Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PWA manifest.json - "theme_color" and "background_color" not working, splash screen not showing on android device

When I look at the manifest.js in Chrome DevTools I can see that the logo and colors are there. However, when I start the website from my homescreen on my android device, neither the background or theme color is loaded, nor my splash screen is shown. Any idea why?

Manifest.json:

{
  "short_name": "Example",
  "name": "Example",
  "icons": [
    {
      "src": "images/logo_192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "images/logo_512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "start_url": "./",
  "display": "standalone",
  "theme_color": "#a300c4",
  "background_color": "#c46a00"
}

Screenshot: Manifest in Chrome Devtools

EDIT

I found the mistake. I was browsing the website via a remote device using the Chrome DevTools. Port-forwarding to localhost:3000 doesn't match the https requirement for the splash screen to get triggered.

Now the pwa starts in standalone mode, the colors and the splash screen are shown correctly.

However, the splash screen logo is not shown and I have no idea why. The path to the image is correct and the image exists with the correct filename and type.

Any suggestions?

like image 841
Apocabal Avatar asked Jun 06 '18 20:06

Apocabal


People also ask

What is Theme_color in manifest?

The theme_color member is a string that defines the default theme color for the application. This sometimes affects how the OS displays the site (e.g., on Android's task switcher, the theme color surrounds the site).

What is PWA manifest?

Web app manifests are part of a collection of web technologies called progressive web apps (PWAs), which are websites that can be installed to a device's homescreen without an app store.

What is the use of manifest JSON?

Using manifest. json , you specify basic metadata about your extension such as the name and version, and can also specify aspects of your extension's functionality (such as background scripts, content scripts, and browser actions).

What is the default splash screen color for Android OS?

Android OS will show the splash as grey/black on Dark Mode and white on Light Mode. I haven't tried using transparent as the theme_color, but I feel like that would be wrong.

Does web app manifest support theme_color meta-tag?

Currently only Chrome and Firefox behind flag manifest.install.enabled supports Web App Manifest, and both says supporting theme_color, what means no need for theme-color meta-tag. I think documentation must be fixed to and require only one of properties, and also mention that valid theme-color would rewrite theme_color value.

Does manifest have theme_color or background_color?

Failures: Manifest does not have background_color, Manifest does not have theme_color. Even though background_color is actually present and set to rgba (0,0,0,0). Sorry, something went wrong.

Why can’t I use icons in my PWAs?

This means that PWAs receive no support for icons, minimal-ui, fullscreen, theme-color, and orientation. Fortunately, there’s still a way around this which is to use the <apple-touch-startup-image> meta tag.


2 Answers

"If you page already has a theme-color meta tag — for example <meta name="theme-color" content="#2196F3"> — then the page level configuration will be used instead of the value in the manifest."

from: https://developers.google.com/web/updates/2015/08/using-manifest-to-set-sitewide-theme-color

like image 85
Crozeta Avatar answered Sep 30 '22 20:09

Crozeta


Only thing I see wrong with this manifest is start URL. Change it to something like below

  "start_url": "/index.html",

or

  "start_url": "https://example.com/myapp/",

If this didn't help, please host your app in some public domain and share the URL.

like image 45
Anand Avatar answered Sep 30 '22 20:09

Anand