1.2.1 • Published 5 years ago

pwa-const-and-invitation v1.2.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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.

PropTypeDefaultDescription
showPwaInvitationbool or function::booltrueValue or function that set PWA invitation visablity
iosInvitationTimeoutint0Milliseconds after last closing PWA invitation on ios to show it again
iosInvitationOnlySafariboolfalseSet to true to show invitation on ios only in Safari
iosInvitationContentstring, 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:

PropTypeDescription
isPwabooltrue if application run as PWA
isIosboolequal true if device based on ios
iosDevicestringiPhone or iPad or iPod
isSafaribooltrue 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

PropTypeDescription
classNamestringCustom css class for icon component

useWindowBeforeInstallPrompt

Hook for default PWA install invitation event

1.2.1

5 years ago

1.2.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago