UNPKG

react-ios-pwa-prompt

Version:

A React component to prompt the user to add the app as a PWA to the home screen with native iOS styles.

45 lines (44 loc) 1.6 kB
import { jsx as S } from "react/jsx-runtime"; import { useEffect as b } from "react"; import { useDeviceAndVersion as P } from "./hooks/useDeviceAndVersion.js"; import { useNumberOfVisits as A } from "./hooks/useNumberOfVisits.js"; import { useShouldShowPrompt as V } from "./hooks/useShouldShowPrompt.js"; import { Container as g } from "./components/Container/Container.js"; const j = ({ appIconPath: e = `https://s2.googleusercontent.com/s2/favicons?domain=${((l) => (l = window == null ? void 0 : window.location) == null ? void 0 : l.origin)()}`, copyAddToHomeScreenStep: t = "Press 'Add to Home Screen'", copyDescription: i = "This website has app functionality. Add it to your home screen to use it in fullscreen and while offline.", copyShareStep: r = "Press the 'Share' button on the menu bar below", copySubtitle: n = String(((a) => (a = window == null ? void 0 : window.location) == null ? void 0 : a.href)()), copyTitle: s = "Add to Home Screen", delay: m = 1e3, isShown: f = void 0, onClose: u = () => { }, promptOnVisit: c = 2, timesToShow: d = 2 }) => { const { isValidOS: o } = P(), { numberOfVisits: h, incrementNumberOfVisits: p } = A(), { shouldShowPrompt: w } = V({ promptOnVisit: c, timesToShow: d, isShown: f }); return b(() => { o && h !== void 0 && p(); }, [o]), w ? /* @__PURE__ */ S( g, { delay: m, copyTitle: s, copySubtitle: n, copyDescription: i, copyShareStep: r, copyAddToHomeScreenStep: t, onClose: u, appIconPath: e } ) : null; }; export { j as default };