Closed all2pie closed 3 years ago
Notification Service Code:
import { Injectable } from '@angular/core';
import { AngularFireMessaging } from '@angular/fire/messaging';
@Injectable()
export class NotificationService {
constructor(private messaging: AngularFireMessaging, private generalService: GeneralService) { }
getPermission() {
this.messaging.requestToken
.subscribe(
(token) => {
console.log('Permission granted! Save to the server!', token);
this.messaging.messages
.subscribe((message) => { console.log(message); });
},
(error) => { console.error(error); },
);
}
}
I am also facing the same issue..
I also cannot get any tokens in Chrome. Haven't tried any other browsers. I'm not getting any errors though.
the only way I got around this is by filling up the firebase service worker file properly, like this
importScripts('https://www.gstatic.com/firebasejs/7.6.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.6.0/firebase-messaging.js');
firebase.initializeApp({
apiKey: “from firebase config”,
authDomain: “from firebase config”,
databaseURL: “from firebase config”,
projectId: “from firebase config”,
storageBucket: “from firebase config”,
messagingSenderId: “from firebase config”,
appId: “from firebase config”,
measurementId: “from firebase config”
});
const messaging = firebase.messaging();
Addressed in recent versions of AngularFire / Firebase.
I am using AngularFireMessaging and getting some issue, did a lot of research, read official docs but could not solve them.
1st issue is that when i send push notification the foreground notification handler crashes (image below), background notifications are working fine and everything is correctly setup.
2nd issue is that i can not get token in chrome, image below:
Kindly help.
Version info
Angular: 8.2.14
Firebase: 7.7.0
AngularFire: 5.3.0