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 setup #1916

Merged
merged 32 commits into from
Jul 18, 2024
Merged

Pwa setup #1916

merged 32 commits into from
Jul 18, 2024

Conversation

Aliiiu
Copy link
Contributor

@Aliiiu Aliiiu commented Jul 1, 2024

PWA Setup

This PR works on setting up PWA for the project

Observation

  • The beforeInstall Prompt needs some requirement to show and it does not show immediately for all devices even after meeting the requirement
Custom Prompt on Android Screenshot 2024-07-10 at 1 46 11 PM
Custom Prompt on iPhone Screenshot 2024-07-10 at 1 46 11 PM

How to test

  • Prompt only shows for mobile screens
  • it only shows once when you just open the app and not every time
  • clear cache to see prompt again

How the Splash Screen looks on android Phones

Installed through Google Pixel Chrome Browser Screenshot 2024-07-10 at 1 46 11 PM
Installed through Samsung Browser Screenshot 2024-07-10 at 1 46 11 PM
Installed through Samsung Chrome Browser Screenshot 2024-07-10 at 1 46 11 PM

How the Home screen looks like on Android and iPhones

Android Homescreen Screenshot 2024-07-10 at 1 46 11 PM
iPhone Homescreen Screenshot 2024-07-10 at 1 46 11 PM

Linked issues

closes EveripediaNetwork/issues#2848
closes EveripediaNetwork/issues#2899

Copy link

stackblitz bot commented Jul 1, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

vercel bot commented Jul 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
iq-wiki ✅ Ready (Inspect) Visit Preview Jul 18, 2024 3:00pm

@kesar
Copy link
Member

kesar commented Jul 1, 2024

long time ago i build some PWA. something I remember its the API caching was tricky to do. Ensure that works fine (no caching unless we know how to do it properly) 👍🏻

@Aliiiu
Copy link
Contributor Author

Aliiiu commented Jul 1, 2024

long time ago i build some PWA. something I remember its the API caching was tricky to do. Ensure that works fine (no caching unless we know how to do it properly) 👍🏻

Alright sir

@Aliiiu
Copy link
Contributor Author

Aliiiu commented Jul 2, 2024

long time ago i build some PWA. something I remember its the API caching was tricky to do. Ensure that works fine (no caching unless we know how to do it properly) 👍🏻

the package I am using does some default caching for the apis, below is the configuration

    urlPattern: ({ url }) => {
      const isSameOrigin = self.origin === url.origin
      if (!isSameOrigin) return false
      const pathname = url.pathname
      // Exclude /api/auth/callback/* to fix OAuth workflow in Safari without impact other environment
      // Above route is default for next-auth, you may need to change it if your OAuth workflow has a different callback route
      // Issue: https://github.com/shadowwalker/next-pwa/issues/131#issuecomment-821894809
      if (pathname.startsWith('/api/auth/')) return false
      if (pathname.startsWith('/api/')) return true
      return false
    },
    handler: 'NetworkFirst',
    method: 'GET',
    options: {
      cacheName: 'apis',
      expiration: {
        maxEntries: 16,
        maxAgeSeconds: 24 * 60 * 60 // 24 hours
      },
      networkTimeoutSeconds: 10 // fall back to cache if api does not response within 10 seconds
    }
  },
  {
    urlPattern: ({ url }) => {
      const isSameOrigin = self.origin === url.origin
      if (!isSameOrigin) return false
      const pathname = url.pathname
      if (pathname.startsWith('/api/')) return false
      return true
    },
    handler: 'NetworkFirst',
    options: {
      cacheName: 'others',
      expiration: {
        maxEntries: 32,
        maxAgeSeconds: 24 * 60 * 60 // 24 hours
      },
      networkTimeoutSeconds: 10
    }
  },
  {
    urlPattern: ({ url }) => {
      const isSameOrigin = self.origin === url.origin
      return !isSameOrigin
    },
    handler: 'NetworkFirst',
    options: {
      cacheName: 'cross-origin',
      expiration: {
        maxEntries: 32,
        maxAgeSeconds: 60 * 60 // 1 hour
      },
      networkTimeoutSeconds: 10
    }
  }

and this is the link to the file
cache.js

@Aliiiu
Copy link
Contributor Author

Aliiiu commented Jul 4, 2024

image

@Adebesin-Cell done with the setup for ios

Copy link
Member

@Softdev1 Softdev1 left a comment

Choose a reason for hiding this comment

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

Nice stuff

@Aliiiu Aliiiu merged commit 38093a8 into main Jul 18, 2024
2 checks passed
@Aliiiu Aliiiu deleted the pwa-setup branch July 18, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants