fix message

This commit is contained in:
Peter Maquiran
2024-10-23 15:30:15 +01:00
parent 4396b17909
commit 5a64376b03
12 changed files with 116 additions and 161 deletions
+23
View File
@@ -44,6 +44,29 @@ export class AppComponent {
this.initializeApp();
this.storage.set('version', environment.version).then(() => {})
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/firebase-messaging-sw.js')
.then(registration => {
console.log('Service Worker registrado com sucesso:', registration);
// Send data to the service worker
if (registration.active) {
registration.active.postMessage({ type: 'INIT_WEBSOCKET', url: 'wss://example.com/socket' });
} else {
navigator.serviceWorker.ready.then(registration => {
registration.active.postMessage({ type: 'INIT_WEBSOCKET', url: 'wss://example.com/socket' });
});
}
})
.catch(error => {
console.error('Erro ao registrar o Service Worker:', error);
});
}
}
}
/* requestPermission() {