pwa-const-and-invitationdeprecated

Few const (isPwa, isIos, iosDevice, isSafari) for PWA in context and ios install invitation component

Usage no npm install needed!

<script type="module">
  import pwaConstAndInvitation from 'https://cdn.skypack.dev/pwa-const-and-invitation';
</script>

README

pwa-const-and-invitation

Few const (isPwa, isIos, iosDevice, isSafari) for PWA in context and ios install invitation component

PwaConstProvider

Component that provide context and iOs PWA Install Invitation. It need to wrap <App/> component with it.

Prop Type Default Description
showPwaInvitation bool or function::bool true Value or function that set PWA invitation visablity
iosInvitationTimeout int 0 Milliseconds after last closing PWA invitation on ios to show it again
iosInvitationOnlySafari bool false Set to true to show invitation on ios only in Safari
iosInvitationContent string, jsx or function(iosDevice) "Install this webapp on your {iosDevice}: tap <IconShareIos /> and then Add to Home Screen" Ios invitation content
import { PwaUtilsProvider, IconShareIos } from 'pwa-const-and-invitation'

ReactDOM.render(
  <PwaUtilsProvider
    showPwaInvitation={true}
    iosInvitationTimeout={10000}
    iosInvitationOnlySafari={true}
    iosInvitationContent={
      (iosDevice)=>
        <Fragment>
          Install my awesome webapp on your {iosDevice}: tap `<IconShareIos />` and then Add to Home Screen
        </Fragment>
    }
  >
    <App />
  </PwaUtilsProvider>
  document.getElementById('root'),
)


withPwaConst

HoC that consume from context following props:

Prop Type Description
isPwa bool true if application run as PWA
isIos bool equal true if device based on ios
iosDevice string iPhone or iPad or iPod
isSafari bool true if it Safari and NOT Chrome
import { withPwa } from 'pwa-const-and-invitation'

const MyAwesomeComponent = withPwa(
  ({ isPwa, isIos, iosDevice, isSafari, ...props }) => {
    ...
  }

IconShareIos

Ios style "Share" icon. You can use it for iosInvitationContent

Prop Type Description
className string Custom css class for icon component

useWindowBeforeInstallPrompt

Hook for default PWA install invitation event