multi-device/installtohomescreen.html

130 строки
6.5 KiB
HTML
Исходник Ответственный История

Этот файл содержит неоднозначные символы Юникода!

Этот файл содержит неоднозначные символы Юникода, которые могут быть перепутаны с другими в текущей локали. Если это намеренно, можете спокойно проигнорировать это предупреждение. Используйте кнопку Экранировать, чтобы подсветить эти символы.

<h1>Add to Homescreen</h1>
<div>
<img src="/chrome/mobile/images/home_add.png" style="width: 25%; height: 25%; float:left; margin-top:-50px"/>
<div style="width:500px">
<p style="margin-top:50px">New in Chrome M31 Beta you can set up your web app to have an application shortcut icon added to a device's homescreen, and have the app launch in full-screen "app mode" using Chrome for Androids "Add to homescreen" menu item.</p>
<p>Homescreen-installed apps work exactly like you would expect a normal web application to work - they follow the same sandboxed security policies and have access to the same APIs - however, they integrate with the Android environment in the following ways.</p>
</div>
</div>
<div style="clear:left"></div>
<div>
<div>
<p><b>Installs directly to the homescreen</b></p>
<p style="width:500px">When a user clicks "Add to homescreen" they will see the app being added on the homescreen.</p>
<img src="/chrome/mobile/images/home_home.png" style="width: 25%; height: 25%" />
</div>
<div>
<p><b>Integrates into the OS task-switcher</b></p>
<p style="width:500px">Web apps launched from the homescreen will appear in the task switcher separate from the browser, they will, however still say "Web App" on the app title.</p>
<img src="/chrome/mobile/images/home_switcher.png" style="width: 25%; height: 25%" />
</div>
</div>
<div style="clear:left"></div>
<div>
<div>
<p><b>Provides a full screen experience</b></p>
<p style="width:500px">Web apps will launch full-screen with no vestiges of a browser. The URL will not be present, nor will traditional browser actions such as bookmarking and navigation controls.</p>
<img src="/chrome/mobile/images/home_full.png" style="width: 25%; height: 25%" />
</div>
<div>
<p><b>Navigating to external pages from a web app highlights them to the user</b></p>
<p style="width:500px">Users will always know if the app routes them to a location outside the applications domain. This is especially useful for authentication flows, the user is kept in the app experience but the URL of the authentication system is clearly visible to the user.</p>
<img src="/chrome/mobile/images/home_navigate.png" style="width: 25%; height: 25%" />
</div>
</div>
<div style="clear:left"></div>
<h2>Supporting add to homescreen apps</h2>
<p>Chrome will look for the following meta tag in the <code>&lt;head&gt;</code> element of the web-page:</p>
<pre>&lt;meta name="mobile-web-app-capable" content="yes"&gt;</pre>
<p>The name attribute MUST be "mobile-web-app-capable" and the content attribute must be "yes" (case in-sensitive). If there is any other value in the content attribute the web app will be added as a regular bookmark.</p>
<h3>Icon</h3>
<p>The icon that is used to install to the homescreen is determined by using the largest icon found in one of the following <code>&lt;link&gt;</code> tags:</p>
<ul>
<li><code>&lt;link rel="shortcut icon" sizes="196x196" href="nice-highres.png"&gt;</code> (recommended)</li>
<li><code>&lt;link rel="shortcut icon" sizes="128x128" href="niceicon.png"&gt;</code></li>
<li><code>&lt;link rel="apple-touch-icon" sizes="128x128" href="niceicon.png"&gt;</code></li>
<li><code>&lt;link rel="apple-touch-icon-precomposed" sizes="128x128" href="niceicon.png"&gt;</code></li>
</ul>
<aside class="caution"><strong>Caution:</strong>The 196px image format is recommended. The last two formats (<code>apple-touch-*</code>) are deprecated, and will be supported only for a short time.</aside>
<h3>Icon label</h3>
<p>The applications <code>&lt;title&gt;</code> element serves as the default label for the icon on the homescreen.</p>
<h3>Configuration</h3>
<p>The following example is the minimum required configuration to support a homescreen launch experience.</p>
<pre>{% htmlescape %}
<!doctype html>
<html>
<head>
<title>Awesome app</title>
<meta name="viewport" content="width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<link rel="shortcut icon" sizes="196x196" href="/icon.png">
</head>
<body></body>
</html>
{% endhtmlescape %}</pre>
<h2>Comparison to iOS Safari Add to Homescreen</h2>
<p>Chrome will also allow Web Apps to launch in "App mode" if they embed a meta tag using the "apple-mobile-web-app-capable" name. Chrome will stop supporting this usage in an upcoming release. Chrome currently shows a deprecation warning in the Developer Tools console log when it detects a page with only the "apple-mobile-web-app-capable" meta tag. The warning appears as follows:</p>
<img src="/chrome/mobile/images/home_warning.png" style="width: 75%; height: 75%" />
<p>Whilst Chrome temporarily accepts the usage of "apple-mobile-web-app-capable", Chrome does not offer compatibility with the iOS Safari APIs including:</p>
<ul>
<li>window.navigator.standalone</li>
<li><code>&lt;meta name="apple-mobile-web-app-status-bar-style" content="black"&gt;</code></li>
<li><code>&lt;link rel="apple-touch-startup-image" href="/startup.png"&gt;</code></li>
</ul>
<h2>Frequently asked questions</h2>
<dl>
<dt>How do I open links in the users browser?</dt>
<dd>As you would on the web, adding target=_blank to an anchor will force the user out of the web app and into the browser that the user added the icon from.</dd>
<dt>Will this work on Chrome for iOS?</dt>
<dd>No.</dd>
<dt>If I visit a page that I have already added to the home screen, will it be full screen?</dt>
<dd>No, whilst you are browsing you will remain in the browser regardless of the fact your web app might be added to the home screen. The page will only launch full screen when launched from the homescreen.</dd>
<dt>How can I detect if the app is running as an installed app?</dt>
<dd>You cant, directly.</dd>
</dl>
<h2>Best practices</h2>
<ul>
<li>Do not prompt the user to add your app to the homescreen. There is no way to detect if the app is running installed or not.</li>
<li>Use the large 196px icon format, as in <code>&lt;link rel="shortcut icon" sizes="196x196" href="nice-highres.png"&gt;</code> for the highest quality homescreen icons.</li>
<li>Use a noun in your documents title with no temporal information.</li>
<li>Use <a href="http://docs.webplatform.org/wiki/apis/appcache/ApplicationCache">AppCache</a> to ensure that your app works or presents the user with an experience when they are offline.</li>
<li>Create a clear icon for use on the home screen following the guidance of <a href="http://developer.android.com/design/style/iconography.html#launcher">Android Iconography</a>.</li>
</ul>