diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf99229 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +### App Deployments +Android +[![PWA Status](https://api.netlify.com/api/v1/badges/b8063611-c1d8-4945-b887-788c1294d644/deploy-status)](https://app.netlify.com/sites/jinnihealth/deploys) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 807a98d..cb4f1b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,6 +46,7 @@ "process": "^0.11.10", "react": "18.2.0", "react-dom": "18.2.0", + "react-helmet-async": "^2.0.5", "react-native": "0.74.3", "react-native-calendars": "^1.1301.0", "react-native-crypto": "^2.2.0", @@ -25612,6 +25613,19 @@ "react": ">=17.0.0" } }, + "node_modules/react-helmet-async": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/react-helmet-async/-/react-helmet-async-2.0.5.tgz", + "integrity": "sha512-rYUYHeus+i27MvFE+Jaa4WsyBKGkL6qVgbJvSBoX8mbsWoABJXdEO0bZyi0F6i+4f0NuIb8AvqPMj3iXFHkMwg==", + "dependencies": { + "invariant": "^2.2.4", + "react-fast-compare": "^3.2.2", + "shallowequal": "^1.1.0" + }, + "peerDependencies": { + "react": "^16.6.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", diff --git a/package.json b/package.json index cd1afec..1496bfd 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dependencies": { "@apollo/client": "^3.8.6", "@arx-research/libhalo": "^1.2.17", + "@expo/metro-runtime": "~3.2.1", "@react-native-async-storage/async-storage": "1.23.1", "@react-native-community/masked-view": "^0.1.11", "@rneui/base": "^4.0.0-rc.7", @@ -50,6 +51,8 @@ "lodash": "^4.17.21", "process": "^0.11.10", "react": "18.2.0", + "react-dom": "18.2.0", + "react-helmet-async": "^2.0.5", "react-native": "0.74.3", "react-native-calendars": "^1.1301.0", "react-native-crypto": "^2.2.0", @@ -65,6 +68,7 @@ "react-native-screens": "3.31.1", "react-native-stream": "^0.1.9", "react-native-svg": "15.2.0", + "react-native-web": "~0.19.10", "readable-stream": "^1.0.33", "stream-browserify": "^1.0.0", "util": "^0.10.4", @@ -79,10 +83,7 @@ "workbox-range-requests": "^6.6.0", "workbox-routing": "^6.6.0", "workbox-strategies": "^6.6.0", - "workbox-streams": "^6.6.0", - "react-native-web": "~0.19.10", - "react-dom": "18.2.0", - "@expo/metro-runtime": "~3.2.1" + "workbox-streams": "^6.6.0" }, "peerDependencies": { "ethers": "5.7.0" diff --git a/public/manifest.json b/public/manifest.json index f2cc9a5..2dca273 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,14 +1,15 @@ { - "short_name": "Jinni Health", + "short_name": "Jinni", "name": "Jinni Health", + "description": "A self-actualiation game based on tamagotchis", "icons": [ { - "src": "public/favicon.png", - "sizes": "192x192", + "src": "favicon.png", + "sizes": "48x48", "type": "image/png" }, { - "src": "public/icon.png", + "src": "icon.png", "sizes": "512x512", "type": "image/png" } diff --git a/src/utils/serviceWorker.js b/public/service-worker.js similarity index 100% rename from src/utils/serviceWorker.js rename to public/service-worker.js diff --git a/src/app/_layout.tsx b/src/app/_layout.tsx index 3f6fb0b..bc3d0f6 100644 --- a/src/app/_layout.tsx +++ b/src/app/_layout.tsx @@ -1,9 +1,7 @@ // add React Native NodeJS polyfills import 'utils/polyfills'; -/** - * Normal RN imports - */ +import { Platform } from 'react-native'; import React, { useEffect, useState } from 'react'; import { Tabs } from 'expo-router'; import * as Sentry from '@sentry/react-native'; @@ -49,7 +47,7 @@ const HomeLayout = () => { ); }; -if (window) { +if (Platform.OS === 'web') { // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://cra.link/PWA diff --git a/src/contexts/ExternalServicesContext.tsx b/src/contexts/ExternalServicesContext.tsx index add57f7..62f3d82 100644 --- a/src/contexts/ExternalServicesContext.tsx +++ b/src/contexts/ExternalServicesContext.tsx @@ -2,6 +2,7 @@ import React, { createContext, useState, useMemo } from 'react'; import { getAppConfig } from 'utils/config'; import { ApolloProvider } from '@apollo/client'; +import { Helmet, HelmetProvider } from 'react-helmet-async'; import { getGqlClient } from 'utils/api'; import { SentryClient, SegmentClient, getSegment, getSentry } from 'utils/logging'; @@ -41,7 +42,12 @@ export const ExternalServicesProvider: React.FC = ({ children }) => { return ( - {children} + + + + + {children} + ); }; diff --git a/src/utils/serviceWorkerRegistration.js b/src/utils/serviceWorkerRegistration.js index ecccce0..35dedc3 100644 --- a/src/utils/serviceWorkerRegistration.js +++ b/src/utils/serviceWorkerRegistration.js @@ -20,7 +20,10 @@ const isLocalhost = Boolean( ); export function register(config) { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + if ( + // process.env.NODE_ENV === 'production' && + 'serviceWorker' in navigator + ) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); if (publicUrl.origin !== window.location.origin) { @@ -30,8 +33,10 @@ export function register(config) { return; } + const url = process.env.PUBLIC_URL || `http://${window.location.host}`; window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + const swUrl = `${url}/service-worker.js`; + console.log('service worker url', url, swUrl); if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. @@ -109,6 +114,7 @@ function checkValidServiceWorker(swUrl, config) { response.status === 404 || (contentType != null && contentType.indexOf('javascript') === -1) ) { + console.log('NO SERVICE WORKER'); // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then((registration) => { registration.unregister().then(() => { @@ -116,6 +122,7 @@ function checkValidServiceWorker(swUrl, config) { }); }); } else { + console.log('SERVICE WORKER REGISTERED'); // Service worker found. Proceed as normal. registerValidSW(swUrl, config); }