Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pwa install prompt for mobile users #1321

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hunar1312
Copy link
Collaborator

resolves #1302

@hunar1312 hunar1312 linked an issue Sep 19, 2024 that may be closed by this pull request
Copy link
Contributor

@DonKoko DonKoko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far.. Please request review when you want me to test what we have so far.

app/components/layout/install-pwa-prompt-modal.tsx Outdated Show resolved Hide resolved
@hunar1312 hunar1312 marked this pull request as ready for review September 26, 2024 13:54
@hunar1312
Copy link
Collaborator Author

Direct PWA installation from prompt modal now works for chromium browsers.

Pending things (input needed) :

  1. Replacing the banner videoof install prompt modal
  2. Need updated and appealing texts for the prompt
  3. Instructions to display for non-chromium browser (ios, firefox, etc.) users on how to install PWA.

@DonKoko
Copy link
Contributor

DonKoko commented Sep 30, 2024

@hunar1312 can you please fix the tests.

Copy link
Contributor

@DonKoko DonKoko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I can still scroll behind when the install prompt is visible

Added some comments in the files themselves. We will provide the content for both iOS and android asap.


try {
const cookieHeader = request.headers.get("Cookie");
const cookie = (await userPrefs.parse(cookieHeader)) || {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you are using the userPrefs cookie, but I think we need to create a different one, as we want it to expire after 14 days so we can remind the user again about it.


export const InstallIcon = (props: SVGProps<SVGSVGElement>) => (
<svg
width="20"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set width and height to 100% so we can control its size based on the parent

<path
d="M6.66667 10L10 13.3333M10 13.3333L13.3333 10M10 13.3333V6.66667M6.5 17.5H13.5C14.9001 17.5 15.6002 17.5 16.135 17.2275C16.6054 16.9878 16.9878 16.6054 17.2275 16.135C17.5 15.6002 17.5 14.9001 17.5 13.5V6.5C17.5 5.09987 17.5 4.3998 17.2275 3.86502C16.9878 3.39462 16.6054 3.01217 16.135 2.77248C15.6002 2.5 14.9001 2.5 13.5 2.5H6.5C5.09987 2.5 4.3998 2.5 3.86502 2.77248C3.39462 3.01217 3.01217 3.39462 2.77248 3.86502C2.5 4.3998 2.5 5.09987 2.5 6.5V13.5C2.5 14.9001 2.5 15.6002 2.77248 16.135C3.01217 16.6054 3.39462 16.9878 3.86502 17.2275C4.3998 17.5 5.09987 17.5 6.5 17.5Z"
stroke="#667085"
stroke-width="1.75"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid jsx and will give errors. Please fix all stroke attributes

import type { loader } from "~/routes/_layout+/_layout";
import { usePwaManager } from "~/utils/pwa-manager";
import { Button } from "../shared/button";
import { useRef } from "react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix import order


const { promptInstall } = usePwaManager();
return optimisticHideInstallPwaPrompt ? null : (
<AnimatePresence>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just like this its not doing anything. You need to add the motion.div inside it. We have some examples. Would be nice to have it animated.

open={true}
>
<div className="relative z-10 rounded-xl bg-white p-4 shadow-lg">
<video height="200" autoPlay loop muted className="mb-6 rounded-lg">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't auto play on my iphone. I think you need to add the inline attribute for it to work.

>
<input type="hidden" name="pwaPromptVisibility" value="hidden" />
<Button type="submit" width="full" variant="secondary">
Skip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip for 2 weeks

@@ -148,6 +150,14 @@ export default function App() {
)}
</div>
<Toaster />
<ClientOnly fallback={null}>
{() =>
window.matchMedia("(max-width: 640px)").matches &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this check into a function with a clear name, so its more obvious what it does.

const context = useContext(PwaManagerContext);

if (context === null) {
throw new Error(`usePwaManager must be used within a PwaManagerProvider.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what that will do. Will it block the page or just throw an error in the console. Do u have an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: PWA install prompt
2 participants