Revision 416593 of App Installation and Management APIs

  • Revision slug: Web/Apps/JavaScript_API
  • Revision title: App Installation and Management APIs
  • Revision id: 416593
  • Created:
  • Creator: kohei.yoshino
  • Is current revision? No
  • Comment Updated links

Revision Content

The Open Web Apps JavaScript API is a programmatic interface for installing Web apps and for managing a client-side collection of Web apps that a user has installed. This collection is called the application repository.

Feature availability

The JavaScript API described here is not yet available in a released version of Firefox (). You can try this API now by using Firefox Beta for Windows and Mac, and Firefox Aurora (pre-beta) for Android.

Mozilla has also implemented a prototype repository (or "dashboard") at myapps.mozillalabs.com for testing and experimentation.

Methods of the API

All methods related to apps are accessed from the navigator.mozApps object. There are two types of functions available in the API:

  • Installation Functions: related to the installation or management of installed apps. These are interesting to stores, self-distributing apps, and app directories.
  • Management Functions: related to the display, launch, or synchronization of apps. Primarily used by dashboards.

Installation API (navigator.mozApps.*)

The apps installation API is exposed as methods on the window.navigator.mozApps object.

Management API (navigator.mozApps.mgmt.*)

The apps management API is privileged. It is intended to grant access to trusted pages, also called "dashboards". The management API exposes functions that let dashboards manage and launch apps on a user's behalf. Additionally, the API exposes functions for app sync, which lets the dashboard display the logged-in state of the user and allows the user to sign up or register for an account to synchronize apps across devices.

Objects

These types of JavaScript objects are used by the apps API:

Old API and the new API

If you were using the older API, it is obsolete as of . The old API is compared with the new API below.

navigator.mozApps.install()
This function has a changed signature.
navigator.mozApps.amInstalled() {{ obsolete_inline() }}
Replaced by navigator.mozApps.getSelf().
navigator.mozApps.getInstalledBy() {{ obsolete_inline() }}
Replaced by navigator.mozApps.getInstalled().
navigator.mozApps.mgmt.list() {{ obsolete_inline() }}
Replaced by navigator.mozApps.mgmt.getAll().
navigator.mozApps.mgmt.watchUpdates(onupdate) {{ obsolete_inline() }}
navigator.mozApps.mgmt.clearWatch(watchId) {{ obsolete_inline() }}
Both of these replaced by navigator.mozApps.oninstall and navigator.mozApps.onuninstall.
navigator.mozApps.mgmt.uninstall(origin, [onsuccess], [onerror]) {{ obsolete_inline() }}
Replaced by navigator.mozApps.mgmt.uninstall(app) where app is an object returned by getAll() or any other function handing app objects.

Revision Source

<p>The Open Web Apps JavaScript API is a programmatic interface for installing Web apps and for managing a client-side collection of Web apps that a user has installed. This collection is called the <em>application repository</em>.</p>
<h2 id="Feature_availability" name="Feature_availability">Feature availability</h2>
<p>The JavaScript API described here is not yet available in a released version of Firefox (<time datetime="2012-11">May 2013</time>). You can try this API now by using <a href="http://www.mozilla.org/en-US/firefox/beta/">Firefox Beta</a> for Windows and Mac, and <a href="http://www.mozilla.org/en-US/firefox/aurora/">Firefox Aurora</a> (pre-beta) for Android.</p>
<p>Mozilla has also implemented a prototype repository (or "dashboard") at <a class="link-https" href="https://myapps.mozillalabs.com/"><code>myapps.mozillalabs.com</code></a> for testing and experimentation.</p>
<h2 id="Methods_of_the_API">Methods of the API</h2>
<p>All methods related to apps are accessed from the <code>navigator.mozApps</code> object. There are two types of functions available in the API:</p>
<ul>
  <li><a href="#Installation_API"><strong>Installation Functions</strong></a>: related to the installation or management of installed apps. These are interesting to stores, self-distributing apps, and app directories.</li>
  <li><a href="#Management_API"><strong>Management Functions</strong></a>: related to the display, launch, or synchronization of apps. Primarily used by dashboards.</li>
</ul>
<h2 id="Installation_API" name="Installation_API">Installation API (<code>navigator.mozApps.*</code>)</h2>
<p>The apps installation API is exposed as methods on the <a href="/en-US/docs/Web/API/window.navigator.mozApps"><code>window.navigator.mozApps</code></a> object.</p>
<ul>
  <li><a href="/en-US/docs/Web/API/Apps.install"><code>navigator.mozApps.install()</code></a></li>
  <li><a href="/en-US/docs/Web/API/Apps.installPackage"><code>navigator.mozApps.installPackage()</code></a></li>
  <li><a href="/en-US/docs/Web/API/Apps.getSelf"><code>navigator.mozApps.getSelf()</code></a></li>
  <li><a href="/en-US/docs/Web/API/Apps.getInstalled"><code>navigator.mozApps.getInstalled()</code></a></li>
  <li><a href="/en-US/docs/Web/API/Apps.checkInstalled"><code>navigator.mozApps.checkInstalled()</code></a></li>
</ul>
<h2 id="Management_API" name="Management_API">Management API (<code>navigator.mozApps.mgmt.*</code>)</h2>
<p>The apps management API is privileged. It is intended to grant access to trusted pages, also called "dashboards". The management API exposes functions that let dashboards manage and launch apps on a user's behalf. Additionally, the API exposes functions for app sync, which lets the dashboard display the logged-in state of the user and allows the user to sign up or register for an account to synchronize apps across devices.</p>
<ul>
  <li><a href="/en-US/docs/Web/API/Apps.mgmt.getAll"><code>navigator.mozApps.mgmt.getAll()</code></a></li>
</ul>
<h2 id="Objects" name="Objects">Objects</h2>
<p>These types of JavaScript objects are used by the apps API:</p>
<ul>
  <li><a href="/en-US/docs/Web/API/App">App objects</a> represent apps.</li>
  <li><a href="/en-US/docs/Web/API/DOMRequest">DOMRequest</a> objects are returned by several methods.</li>
  <li><a href="/en-US/docs/Web/API/DOMError">DOMError objects</a> represent errors returned by methods.</li>
</ul>
<h2 id="Old_API_and_the_new_API" name="Old_API_and_the_new_API">Old API and the new API</h2>
<p>If you were using the older API, it is obsolete as of <time datetime="2012-03">March 2012</time>. The old API is compared with the new API below.</p>
<dl>
  <dt>
    <a href="/en-US/docs/Web/API/Apps.install">navigator.mozApps.install()</a></dt>
  <dd>
    This function has a changed signature.</dd>
  <dt>
    <a href="/en-US/docs/Web/Apps/JavaScript_API/navigator.mozApps.amInstalled">navigator.mozApps.amInstalled()</a> {{ obsolete_inline() }}</dt>
  <dd>
    Replaced by <a href="/en-US/docs/Web/API/Apps.getSelf"><code>navigator.mozApps.getSelf()</code></a>.</dd>
  <dt>
    <a href="/en-US/docs/Web/Apps/JavaScript_API/navigator.mozApps.getInstalledBy">navigator.mozApps.getInstalledBy()</a> {{ obsolete_inline() }}</dt>
  <dd>
    Replaced by <a href="/en-US/docs/Web/API/Apps.getInstalled"><code>navigator.mozApps.getInstalled()</code></a>.</dd>
  <dt>
    <a href="/en-US/docs/Web/Apps/JavaScript_API/navigator.mozApps.mgmt.list">navigator.mozApps.mgmt.list()</a> {{ obsolete_inline() }}</dt>
  <dd>
    Replaced by <a href="/en-US/docs/Web/API/Apps.mgmt.getAll"><code>navigator.mozApps.mgmt.getAll()</code></a>.</dd>
  <dt>
    <a href="/en-US/docs/Web/Apps/JavaScript_API/navigator.mozApps.mgmt.watchUpdates">navigator.mozApps.mgmt.watchUpdates(onupdate)</a> {{ obsolete_inline() }}<br />
    <a href="/en-US/docs/Web/Apps/JavaScript_API/navigator.mozApps.mgmt.clearWatch">navigator.mozApps.mgmt.clearWatch(watchId)</a> {{ obsolete_inline() }}</dt>
  <dd>
    Both of these replaced by <a href="/en-US/docs/Web/API/Apps.oninstall"><code>navigator.mozApps.oninstall</code></a> and <a href="/en-US/docs/Web/API/Apps.onuninstall"><code>navigator.mozApps.onuninstall</code></a>.</dd>
  <dt>
    <a href="/en-US/docs/Web/Apps/JavaScript_API/navigator.mozApps.mgmt.uninstall">navigator.mozApps.mgmt.uninstall(origin, [onsuccess], [onerror])</a> {{ obsolete_inline() }}</dt>
  <dd>
    Replaced by <code>navigator.mozApps.mgmt.uninstall(app)</code> where <code>app</code> is an object returned by <a href="/en-US/docs/Web/API/Apps.mgmt.getAll"><code>getAll()</code></a> or any other function handing <code>app</code> objects.</dd>
</dl>
Revert to this revision