Esta tradução está incompleta. Ajude atraduzir este artigo.
The web app manifest provides information about an application (such as name, author, icon, and description) in a text file. The purpose of the manifest is to install web applilcations to the homescreen of a device, providing users with quicker access and a richer experience.
Web app manifests are part of a collection of web technologies called progressive web apps, which are web applications that can be installed to the homescreen of a device without needing the user to go through an app store, along with other superpowers such as being available offline and presenting users with push notifications when application content changes.
Implementando um manifest
Manifest de aplicativos Web são implementados em suas páginas HTML usando a tag link no header do documento:
<link rel="manifest" href="/manifest.json">
Exemplo de manifest
{ "name": "HackerWeb", "short_name": "HackerWeb", "start_url": ".", "display": "standalone", "background_color": "#fff", "description": "A simply readable Hacker News app.", "icons": [{ "src": "images/touch/homescreen48.png", "sizes": "48x48", "type": "image/png" }, { "src": "images/touch/homescreen72.png", "sizes": "72x72", "type": "image/png" }, { "src": "images/touch/homescreen96.png", "sizes": "96x96", "type": "image/png" }, { "src": "images/touch/homescreen144.png", "sizes": "144x144", "type": "image/png" }, { "src": "images/touch/homescreen168.png", "sizes": "168x168", "type": "image/png" }, { "src": "images/touch/homescreen192.png", "sizes": "192x192", "type": "image/png" }], "related_applications": [{ "platform": "web" }, { "platform": "play", "url": "https://play.google.com/store/apps/details?id=cheeaun.hackerweb" }] }
Membros
background_color
Defines the expected background color for the web application. This value repeats what is already available in the application stylesheet, but can be used by browsers to draw the background color of a web application when the manifest is available before the style sheet has loaded. This creates a smooth transition between launching the web application and loading the application's content.
"background_color": "red"
Note: The background_color
member is only meant to improve the user experience while a web application is loading and must not be used by the user agent as the background color when the web application's stylesheet is available.
description
Fornece uma descrição geral do que a aplicação faz.
"description": "The app that helps you find the best food in town!"
dir
Specifies the primary text direction for the name
, short_name
, and description
members. Together with the lang
member, it can help provide the correct display of right-to-left languages.
"dir": "rtl", "lang": "ar", "short_name": "أنا من التطبيق!"
It may be one of the following values:
ltr
(left-to-right)rtl
(right-to-left)auto
(hints to the browser to use the Unicode bidirectional algorithm to make a best guess about the text's direction.)
Note: When the value is omitted, it defaults to auto
.
display
Define o modo de exibição preferido do desenvolvedor para a aplicação.
"display": "standalone"
Valid values are:
Display Mode | Description | Fallback Display Mode |
---|---|---|
fullscreen |
All of the available display area is used and no user agent chrome is shown. | standalone |
standalone |
The application will look and feel like a standalone application. This can include the application having a different window, its own icon in the application launcher, etc. In this mode, the user agent will exclude UI elements for controlling navigation, but can include other UI elements such as a status bar. | minimal-ui |
minimal-ui |
The application will look and feel like a standalone application, but will have a minimal set of UI elements for controlling navigation. The elements will vary by browser. | browser |
browser |
The application opens in a conventional browser tab or new window, depending on the browser and platform. This is the default. | (None) |
Note: You can selectively apply CSS to your app based on the display mode, using the display-mode media feature. This can be used to provide a consistent user experience between launching a site from an URL and launching it from a desktop icon.
icons
Specifies an array of image objects that can serve as application icons in various contexts. For example, they can be used to represent the web application amongst a list of other applications, or to integrate the web application with an OS's task switcher and/or system preferences.
"icons": [ { "src": "icon/lowres.webp", "sizes": "48x48", "type": "image/webp" }, { "src": "icon/lowres", "sizes": "48x48" }, { "src": "icon/hd_hi.ico", "sizes": "72x72 96x96 128x128 256x256" }, { "src": "icon/hd_hi.svg", "sizes": "72x72" } ]
Objetos de imagens podem conter os seguintes valores:
Member | Description |
---|---|
sizes |
A string containing space-separated image dimensions. |
src |
The path to the image file. |
type |
A hint as to the media type of the image.The purpose of this member is to allow a user agent to quickly ignore images of media types it does not support. |
lang
Specifies the primary language for the values in the name
and short_name
members. This value is a string containing a single language tag.
"lang": "en-US"
name
Provides a human-readable name for the application as it is intended to be displayed to the user, for example among a list of other applications or as a label for an icon.
"name": "Google I/O 2015"
orientation
Defines the default orientation for all the web application's top level browsing contexts.
"orientation": "portrait-primary"
Orientation pode ser um dos seguintes valores:
any
natural
landscape
landscape-primary
landscape-secondary
portrait
portrait-primary
portrait-secondary
prefer_related_applications
Specifies a boolean value that hints for the user agent to indicate to the user that the specified related applications (see below) are available, and recommended over the web application. This should only be used if the related native apps really do offer something that the web application can't do.
"prefer_related_applications": false
Note: If omitted, the value defaults to false
.
related_applications
Specifies an array of "application objects" representing native applications that are installable by, or accessible to, the underlying platform — for example a native Android application obtainable through the Google Play Store. Such applications are intended to be alternatives to the web application that provide similar or equivalent functionality — like the native app version of the web app.
"related_applications": [ { "platform": "play", "url": "https://play.google.com/store/apps/details?id=com.example.app1", "id": "com.example.app1" }, { "platform": "itunes", "url": "https://itunes.apple.com/app/example-app1/id123456789" }]
Application objects may contain the following values:
Member | Description |
---|---|
platform |
The platform on which the application can be found. |
url |
The URL at which the application can be found. |
id |
The ID used to represent the application on the specified platform. |
scope
Defines the navigation scope of this web application's application context. This basically restricts what web pages can be viewed while the manifest is applied. If the user navigates the application outside the scope, it returns to being a normal web page.
"scope": "/myapp/"
short_name
Provides a short human-readable name for the application. This is intended for use where there is insufficient space to display the full name of the web application.
"short_name": "I/O 2015"
start_url
Specifies the URL that loads when a user launches the application from a device.
"start_url": "./?utm_source=web_app_manifest"
theme_color
Defines the default theme color for an application. This sometimes affects how the application is displayed by the OS (e.g., on Android's task switcher, the theme color surrounds the application).
"theme_color": "aliceblue"
Splash screens
In Chrome 47 and later, a splash screen is displayed for a web application launched from a home screen. This splashscreen is auto-generated using properties in the web app manifest, specifically: name
, background_color
, and the icon in the icons
array that is closest to 128dpi for the device.
Mime type
Manifests should be served using the application/manifest+json
MIME type. However, it is optional to do so.
Specification
Specification | Status | Comment |
---|---|---|
Web App Manifest | Working Draft | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | Não suportado | Não suportado | Não suportado | Não suportado | Não suportado |
background_color |
Não suportado | Não suportado | Não suportado | Não suportado | Não suportado |
theme_color |
Não suportado | Não suportado | Não suportado | Não suportado | Não suportado |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | Não suportado | 39.0 | ? | ? | ? | 32.0 | ? | 39.0 |
background_color |
Não suportado | 46.0 [1] | ? | ? | ? | (Yes) | ? | 46.0 [1] |
theme_color |
Não suportado | 46.0 [1] | ? | ? | ? | Não suportado | ? | 46.0 [1] |
[1] Does not support lang
or scope
.