cent os 火狐_在任何域上安装Firefox OS应用

cent os 火狐

The app store models we've grown up with suck:  you have to install apps from within those stores.  With iOS you go to a site, they provide a link to install their app, and you get swapped from the browser to the App store.  What an awful user experience.  The brilliant minds at Mozilla have found the solution to this annoying problem:  an installation system via the browser.  Let me show you how you can install your Firefox app outside of the Firefox Marketplace.

我们在应用商店中成长的模型很烂:您必须在这些商店中安装应用。 使用iOS,您可以访问网站,他们提供安装其应用程序的链接,并且您从浏览器切换到App Store。 多么糟糕的用户体验。 Mozilla的才华横溢的人们找到了解决这一烦人问题的解决方案:通过浏览器安装系统。 让我向您展示如何在Firefox Marketplace外部安装Firefox应用程序。

第一部分:manifest.webapp (Part One:  manifest.webapp)

Every Firefox OS app requires an manifest.webapp file and one of the manifest keys is installs_allowed_from, an array of hostnames which the app may be installed from:

每个Firefox OS应用程序都需要一个manifest.webapp文件,其中的清单密钥之一是installs_allowed_from ,可以从中安装应用程序的主机名数组:


{
  "version": "0.1",
  "name": "My App",
  "description": "My new awesome Open Web App",
  "developer": {
    "name": "Your Name",
    "url": "http://yourawesomeapp.com"
  },
  "installs_allowed_from": [
    "https://marketplace.mozilla.org",
  "https://davidwalsh.name"
  ]
}



Add the domain(s) you'd like to the installs_allowed_from array and you're golden.  Note that if you set the value of installs_allowed_from to ["*"], the app can be installed from any domain.

将您想要的域添加到installs_allowed_from数组中,您会很高兴。 请注意,如果将installs_allowed_from的值设置为["*"] ,则可以从任何域安装该应用程序。

第二部分:navigator.mozApps.install (Part Two:  navigator.mozApps.install)

The navigator.mozApps.install method triggers an installation of a web app on desktop or mobile device:

navigator.mozApps.install方法触发在桌面或移动设备上安装Web应用程序:


var manifestLocation = "https://davidwalsh.name/manifest.webapp"; // your domain here
var installRequest = navigator.mozApps.install(manifestLocation);

installRequest.onsuccess = function(data) {
    // App installed successfully!
};

installRequest.onerror = function(err) {
    // App couldn't be installed!
    console.log("Install error!");
};


The install method accepts a URL to the app's manifest.  The resulting object provides onsuccess and onerror callbacks to allow developers to respond to the result (i.e. hide the install button or display the install error).

install方法接受指向应用清单的URL。 结果对象提供onsuccessonerror回调,以允许开发人员响应结果(即,隐藏安装按钮或显示安装错误)。

The ability to install a Firefox OS app from any domain is a bonus you haven't gotten with iOS; this META tag is the closest you'll get.  Create a compatible manifest.webapp file and utilize navigator.mozApps.install to install your app from any qualifying domain.  Isn't Firefox OS' app install model beautiful?

从任何域安装Firefox OS应用程序的能力都是iOS所没有的。 这个META标签是最接近您的 。 创建一个兼容的manifest.webapp文件,并利用navigator.mozApps.install从任何合格的域中安装您的应用程序。 Firefox OS的应用安装模型不是很漂亮吗?

翻译自: https://davidwalsh.name/install-firefoxos-app

cent os 火狐

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值