Skip to content

Commit ec32369

Browse files
committed
v1.0.5: add service worker sw.js and +html.tsx to enable PWA standalone installability
1 parent f7d439a commit ec32369

8 files changed

Lines changed: 96 additions & 2 deletions

File tree

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "makyaj",
44
"slug": "makyaj",
5-
"version": "1.0.4",
5+
"version": "1.0.5",
66
"orientation": "portrait",
77
"icon": "./assets/images/icon.png",
88
"scheme": "makyaj",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "makyaj",
33
"main": "expo-router/entry",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"dependencies": {
66
"@expo/ui": "~56.0.14",
77
"@react-native-async-storage/async-storage": "^3.1.0",

public/favicon.png

1.1 KB
Loading

public/icon-192.png

780 KB
Loading

public/icon-512.png

780 KB
Loading

public/manifest.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "GlowPrice ✨",
3+
"short_name": "GlowPrice",
4+
"description": "En Ucuz Makyaj Alışverişi ve Fiyat Karşılaştırma",
5+
"start_url": "/",
6+
"display": "standalone",
7+
"background_color": "#FFF5F5",
8+
"theme_color": "#E8A7B5",
9+
"orientation": "portrait",
10+
"icons": [
11+
{
12+
"src": "/icon-192.png",
13+
"sizes": "192x192",
14+
"type": "image/png"
15+
},
16+
{
17+
"src": "/icon-512.png",
18+
"sizes": "512x512",
19+
"type": "image/png"
20+
}
21+
]
22+
}

public/sw.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const CACHE_NAME = 'glowprice-cache-v1';
2+
const urlsToCache = [
3+
'/',
4+
'/index.html',
5+
'/manifest.json',
6+
'/favicon.png',
7+
'/icon-192.png',
8+
'/icon-512.png'
9+
];
10+
11+
self.addEventListener('install', event => {
12+
event.waitUntil(
13+
caches.open(CACHE_NAME)
14+
.then(cache => cache.addAll(urlsToCache))
15+
);
16+
});
17+
18+
self.addEventListener('fetch', event => {
19+
event.respondWith(
20+
caches.match(event.request)
21+
.then(response => {
22+
if (response) {
23+
return response;
24+
}
25+
return fetch(event.request);
26+
})
27+
);
28+
});

src/app/+html.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import { ScrollViewStyleReset } from 'expo-router/html';
3+
4+
export default function HTML({ children }: { children: React.ReactNode }) {
5+
return (
6+
<html lang="tr">
7+
<head>
8+
<meta charSet="utf-8" />
9+
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
10+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
11+
12+
{/* Link Manifest for PWA */}
13+
<link rel="manifest" href="/manifest.json" />
14+
<meta name="theme-color" content="#E8A7B5" />
15+
16+
{/* PWA iOS support */}
17+
<meta name="apple-mobile-web-app-capable" content="yes" />
18+
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
19+
<meta name="apple-mobile-web-app-title" content="GlowPrice" />
20+
<link rel="apple-touch-icon" href="/icon-192.png" />
21+
22+
<ScrollViewStyleReset />
23+
</head>
24+
<body>
25+
{children}
26+
27+
{/* Register Service Worker */}
28+
<script
29+
dangerouslySetInnerHTML={{
30+
__html: `
31+
if ('serviceWorker' in navigator) {
32+
window.addEventListener('load', () => {
33+
navigator.serviceWorker.register('/sw.js')
34+
.then(reg => console.log('Service Worker registered successfully:', reg.scope))
35+
.catch(err => console.log('Service Worker registration failed:', err));
36+
});
37+
}
38+
`,
39+
}}
40+
/>
41+
</body>
42+
</html>
43+
);
44+
}

0 commit comments

Comments
 (0)