Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions apps/web/components/pwa-install-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,20 @@ export function PWAInstallPrompt() {
dismiss()
}, [nativePrompt, dismiss])

const openShareMenu = useCallback(async () => {
try {
if (typeof navigator !== "undefined" && "share" in navigator) {
await navigator.share({
title: "Supermemory",
url: window.location.href,
})
}
} catch {}
dismiss()
}, [dismiss])

const canNativeInstall = !!nativePrompt && device.isAndroid && device.isChrome
const canShare = typeof navigator !== "undefined" && "share" in navigator
const steps = buildSteps(device)

return (
Expand Down Expand Up @@ -347,10 +360,20 @@ export function PWAInstallPrompt() {

<Button
variant="insideOut"
onClick={canNativeInstall ? handleInstall : dismiss}
onClick={
canNativeInstall
? handleInstall
: canShare
? openShareMenu
: dismiss
}
className={cn("h-12 w-full px-5 text-[15px]", dmSansClassName())}
>
{canNativeInstall ? "Install now" : "Got it"}
{canNativeInstall
? "Install now"
: canShare
? "Add to Home Screen"
: "Got it"}
</Button>
</div>
</DrawerContent>
Expand Down
Loading