Giter Site home page Giter Site logo

s0xdk / pwa-install Goto Github PK

View Code? Open in Web Editor NEW

This project forked from khmyznikov/pwa-install

0.0 0.0 0.0 1.73 MB

Installation dialog for Progressive Web Application. Provides a more convenient user experience and fixes the lack of native dialogs in some browsers.

Home Page: https://www.khmyznikov.com/pwa-install

License: MIT License

JavaScript 7.38% TypeScript 57.71% SCSS 34.91%

pwa-install's Introduction

Published on NPM npm

<pwa-install>

Installation dialog for Progressive web application. Provides more convenience user experience and fix lack of native dialogs in some browsers. 13.5kB brotli compressed bundle. Translation/localization is supported.

Use it as Web Component with any modern framework. No polyfill is required.

Gallery

iOS default       Install instruction App gallery       
iOS example default iOS example install instruction iOS example gallery
iPadOS
iPadOS example white
Android App gallery   White theme  
Android example default Android example gallery Android example white
Chrome  App Gallery  
Chrome example default Chrome example gallery

Install

npm i @khmyznikov/pwa-install

Alternatively, you can use unpkg.

Import

import '@khmyznikov/pwa-install';

Use

<pwa-install></pwa-install>

Supported params

<pwa-install
  manual-apple="true"
  manual-chrome="true"
  disable-chrome="true"

  install-description="Custom call to install text"
  disable-install-description="true"

  manifest-url="/manifest.json"
  name="PWA"
  description="Progressive web application"         
  icon="/icon.png">
</pwa-install>
<!-- 
  manual-apple/chrome params means you want to show the Dialog manually by showDialog().
  disable-chrome param is for completely disabling custom logic and interception for Chominum browsers (will work built-in browser logic).
--->

Make a good manifest file and don't use name/descr/icon params. Boolean attributes needs to be removed to act like "false"


Supported events

  • pwa-install-success-event
  • pwa-install-fail-event
  • pwa-install-available-event
  • pwa-user-choice-result-event
<script type="text/javascript">
  var pwaInstall = document.getElementsByTagName('pwa-install')[0];

  pwaInstall.addEventListener('pwa-install-success-event', (event) => {console.log(event.detail.message)});
</script>

⚠️ success/fail/choice events is Chromium only, iOS don't have them.


Supported properties (readonly)

  • userChoiceResult: string;
  • isDialogHidden: boolean
  • isInstallAvailable: boolean
  • isAppleMobilePlatform: boolean
  • isUnderStandaloneMode: boolean
  • isRelatedAppsInstalled: boolean
<script type="text/javascript">
  var pwaInstall = document.getElementsByTagName('pwa-install')[0];

  console.log(pwaInstall.isUnderStandaloneMode);
</script>

Supported methods

  • install
  • hideDialog
  • showDialog
  • getInstalledRelatedApps: async
<script type="text/javascript">
  var pwaInstall = document.getElementsByTagName('pwa-install')[0];

  pwaInstall.install();
</script>

getInstalledRelatedApps is Chromium only, always empty on iOS.


Supported localization

Translations available:

  • EN
  • RU
  • TR
  • DE
  • ES
  • NL
  • EL
  • FR
  • SR
  • PL
  • ZH/ZH-CN
  • IT
  • UK

Language should change automatically based on browser settings. Please create the pull-request if you want to help with translation to your language. It's an easy process.

Contribution Guidelines


ROADMAP

  • style customization

pwa-install's People

Contributors

khmyznikov avatar showerzen avatar dartess avatar blankjr avatar jivanf avatar mertcandinler avatar georgegipa avatar benfavre avatar horacy avatar s0xdk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.