3.2 KiB
3.2 KiB
🚀 Push Notifications Setup - Ninja Cross
✅ Status: Vollständig funktionsfähig!
Alle PWA Push Notification Probleme wurden behoben:
🔧 Was wurde behoben:
- ✅ VAPID Keys generiert und konfiguriert
- ✅ Push Service Backend erstellt (
push-service.js) - ✅ API Endpoints für Push erweitert
- ✅ Manifest.json Icons korrigiert (PNG statt ICO)
- ✅ Service Worker Icons aktualisiert
- ✅ HTTPS funktioniert über Apache2 Proxy
- ✅ UUID-Fehler behoben (anonymous users bekommen UUID)
- ✅ 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:
- Safari öffnen und zu
https://ninja.reptilfpv.de/test-push.htmlgehen - "Berechtigung anfordern" klicken → iOS fragt nach Notification-Permission
- "Push abonnieren" klicken → Service Worker registriert Push Subscription
- "Test-Push senden" klicken → Push Notification wird gesendet
3. PWA installieren (für bessere iPhone-Integration):
- In Safari: "Teilen" → "Zum Home-Bildschirm hinzufügen"
- Die App wird als PWA installiert
- Push Notifications funktionieren auch wenn die App geschlossen ist
🔧 API Endpoints:
Push Subscription:
POST /api/v1/public/subscribe
Content-Type: application/json
{
"endpoint": "https://fcm.googleapis.com/fcm/send/...",
"keys": {
"p256dh": "...",
"auth": "..."
}
}
Test Push:
POST /api/v1/public/test-push
Content-Type: application/json
{
"userId": "user-uuid",
"message": "Test Message"
}
Push Status:
GET /api/v1/public/push-status
🎯 Automatische Push Notifications:
Push Notifications werden automatisch gesendet bei:
- 🏆 Neue Achievements - Wenn ein Spieler ein Achievement erreicht
- 🏁 Best Times - Täglich um 19:00 für beste Tageszeit
- 📅 Weekly Best - Sonntags um 19:00 für beste Wochenzeit
- 📆 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:
- Teste auf dem iPhone:
https://ninja.reptilfpv.de/test-push.html - PWA installieren für bessere Integration
- 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! 🎉