Hi,
I can request permission but when i try to get token I get this error below
from firebase messaging
* We are unable to register the default service worker. Failed to register
a ServiceWorker for scope
('http://localhost:4200/firebase-cloud-messaging-push-scope') with script
('http://localhost:4200/firebase-messaging-sw.js'): A bad HTTP response
code (404) was received when fetching the script.
(messaging/failed-service-worker-registration).*
I use code snippet below from angularFire to test messaging. Inside my
app.component.ts file
*import { Component } from '@angular/core';*
*import { AngularFireMessaging } from '@angular/fire/messaging';*
*import { mergeMapTo } from 'rxjs/operators';*
*@Component({*
* selector: 'app-root',*
* template: `*
* <button (click)="requestPermission()">*
* Hello this is a chat app. You should let us send you notifications for
this reason.*
* </button>*
* `*
*})*
*export class AppComponent {*
* constructor(private afMessaging: AngularFireMessaging) { }*
* requestPermission() {*
* this.afMessaging.requestPermission*
* .pipe(mergeMapTo(this.afMessaging.tokenChanges))*
* .subscribe(*
* (token) => { console.log('Permission granted! Save to the server!',
token); },*
* (error) => { console.error(error); },*
* );*
* }*
*}*
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/a718f0e6-1a34-419d-b08d-4f38fb3c2c0cn%40googlegroups.com.