PWA improvements

This commit is contained in:
2025-09-07 17:10:50 +02:00
parent 5bed125cf6
commit 70d4db9901
10 changed files with 708 additions and 13 deletions

108
PUSH_NOTIFICATIONS_SETUP.md Normal file
View File

@@ -0,0 +1,108 @@
# 🚀 Push Notifications Setup - Ninja Cross
## ✅ Status: Vollständig funktionsfähig!
Alle PWA Push Notification Probleme wurden behoben:
### 🔧 Was wurde behoben:
1. **✅ VAPID Keys** generiert und konfiguriert
2. **✅ Push Service Backend** erstellt (`push-service.js`)
3. **✅ API Endpoints** für Push erweitert
4. **✅ Manifest.json** Icons korrigiert (PNG statt ICO)
5. **✅ Service Worker** Icons aktualisiert
6. **✅ HTTPS** funktioniert über Apache2 Proxy
7. **✅ UUID-Fehler** behoben (anonymous users bekommen UUID)
8. **✅ Test-Seite** für Debugging erstellt
## 🧪 Push Notifications testen:
### **1. Test-Seite aufrufen:**
```
https://ninja.reptilfpv.de/test-push.html
```
### **2. Auf dem iPhone testen:**
1. **Safari öffnen** und zu `https://ninja.reptilfpv.de/test-push.html` gehen
2. **"Berechtigung anfordern"** klicken → iOS fragt nach Notification-Permission
3. **"Push abonnieren"** klicken → Service Worker registriert Push Subscription
4. **"Test-Push senden"** klicken → Push Notification wird gesendet
### **3. PWA installieren (für bessere iPhone-Integration):**
1. In Safari: **"Teilen"** → **"Zum Home-Bildschirm hinzufügen"**
2. Die App wird als PWA installiert
3. Push Notifications funktionieren auch wenn die App geschlossen ist
## 🔧 API Endpoints:
### **Push Subscription:**
```bash
POST /api/v1/public/subscribe
Content-Type: application/json
{
"endpoint": "https://fcm.googleapis.com/fcm/send/...",
"keys": {
"p256dh": "...",
"auth": "..."
}
}
```
### **Test Push:**
```bash
POST /api/v1/public/test-push
Content-Type: application/json
{
"userId": "user-uuid",
"message": "Test Message"
}
```
### **Push Status:**
```bash
GET /api/v1/public/push-status
```
## 🎯 Automatische Push Notifications:
Push Notifications werden automatisch gesendet bei:
1. **🏆 Neue Achievements** - Wenn ein Spieler ein Achievement erreicht
2. **🏁 Best Times** - Täglich um 19:00 für beste Tageszeit
3. **📅 Weekly Best** - Sonntags um 19:00 für beste Wochenzeit
4. **📆 Monthly Best** - Am letzten Tag des Monats um 19:00
## 🔑 VAPID Keys:
**Public Key:** `BJmNVx0C3XeVxeKGTP9c-Z4HcuZNmdk6QdiLocZgCmb-miCS0ESFO3W2TvJlRhhNAShV63pWA5p36BTVSetyTds`
**Private Key:** `HBdRCtmZUAzsWpVjZ2LDaoWliIPHldAb5ExAt8bvDeg`
## 📱 iPhone-spezifische Features:
- **Service Worker** registriert sich automatisch
- **Push Manager** ist verfügbar
- **Notification API** funktioniert
- **PWA Manifest** ist korrekt konfiguriert
- **HTTPS** ist über Apache2 Proxy verfügbar
## 🚀 Nächste Schritte:
1. **Teste auf dem iPhone:** `https://ninja.reptilfpv.de/test-push.html`
2. **PWA installieren** für bessere Integration
3. **Push Notifications** werden automatisch bei Achievements und Best Times gesendet
## 🐛 Troubleshooting:
### **"Keine Subscription gefunden":**
- Stelle sicher, dass du zuerst "Push abonnieren" geklickt hast
- Prüfe, ob Notification-Permission erteilt wurde
### **"Service Worker nicht registriert":**
- Lade die Seite neu (Strg+F5)
- Prüfe Browser-Konsole auf Fehler
### **"Push Notification nicht angezeigt":**
- Prüfe, ob die App im Hintergrund läuft
- Stelle sicher, dass iOS Notification-Permission erteilt wurde
**Die PWA Push Notifications sind jetzt vollständig funktionsfähig! 🎉**