Firebase Messaging WIP to clean up service worker and implement proper notifications.
Missed in last commit
This commit is contained in:
@@ -31,23 +31,6 @@ class FcmNotificationComponent extends Component {
|
||||
console.log("Unable to get permission to notify.", err);
|
||||
logImEXEvent("fcm_permission_denied", { message: err });
|
||||
});
|
||||
navigator.serviceWorker.addEventListener("message", (message) => {
|
||||
const { payload } = message.data.firebaseMessaging;
|
||||
|
||||
navigator.serviceWorker.getRegistration().then((registration) =>
|
||||
registration.showNotification(payload.notification.title, {
|
||||
body: payload.notification.body,
|
||||
icon: "logo240.png",
|
||||
badge: "logo240.png",
|
||||
actions: [
|
||||
{
|
||||
action: "respond",
|
||||
title: "Respond",
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -59,3 +42,15 @@ export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(withApollo(FcmNotificationComponent));
|
||||
|
||||
//Firebase Service Worker Register
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register("/firebase-messaging-sw.js")
|
||||
.then(function (registration) {
|
||||
console.log("**********FCM Registration successful, scope is:", registration.scope);
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.log("**********FCM Service worker registration failed, error:", err);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user