Removed mandatory loading of firebase messaging as it does not support Safari.
This commit is contained in:
@@ -12,3 +12,7 @@ npx hasura console --admin-secret Dev-BodyShopAppBySnaptSoftware!
|
|||||||
|
|
||||||
Migrating to Staging:
|
Migrating to Staging:
|
||||||
npx hasura migrate apply --up 10 --endpoint https://bodyshop-staging-db.herokuapp.com/ --admin-secret Staging-BodyShopAppBySnaptSoftware!
|
npx hasura migrate apply --up 10 --endpoint https://bodyshop-staging-db.herokuapp.com/ --admin-secret Staging-BodyShopAppBySnaptSoftware!
|
||||||
|
|
||||||
|
NGROK TEsting:
|
||||||
|
|
||||||
|
./ngrok.exe http https://localhost:5000 -host-header="localhost:5000"
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import { notification } from "antd";
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { messaging } from "../../firebase/firebase.utils";
|
|
||||||
import { withApollo } from "react-apollo";
|
import { withApollo } from "react-apollo";
|
||||||
import { UPDATE_FCM_TOKEN } from "../../graphql/user.queries";
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { messaging } from "../../firebase/firebase.utils";
|
||||||
|
import { UPDATE_FCM_TOKEN } from "../../graphql/user.queries";
|
||||||
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
@@ -16,6 +15,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
class FcmNotificationComponent extends Component {
|
class FcmNotificationComponent extends Component {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const { client, currentUser } = this.props;
|
const { client, currentUser } = this.props;
|
||||||
|
if (!!!messaging) return; //Skip all of the notification functionality if the firebase SDK could not start.
|
||||||
|
|
||||||
messaging
|
messaging
|
||||||
.requestPermission()
|
.requestPermission()
|
||||||
.then(async function () {
|
.then(async function () {
|
||||||
@@ -31,7 +32,6 @@ class FcmNotificationComponent extends Component {
|
|||||||
});
|
});
|
||||||
navigator.serviceWorker.addEventListener("message", (message) => {
|
navigator.serviceWorker.addEventListener("message", (message) => {
|
||||||
const { payload } = message.data.firebaseMessaging;
|
const { payload } = message.data.firebaseMessaging;
|
||||||
// notification["info"]({ message: JSON.stringify(payload) });
|
|
||||||
|
|
||||||
navigator.serviceWorker.getRegistration().then((registration) =>
|
navigator.serviceWorker.getRegistration().then((registration) =>
|
||||||
registration.showNotification(payload.notification.title, {
|
registration.showNotification(payload.notification.title, {
|
||||||
@@ -50,7 +50,7 @@ class FcmNotificationComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <div></div>;
|
return <span />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,16 @@ export const updateCurrentUser = (userDetails) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const messaging = firebase.messaging();
|
let messaging;
|
||||||
messaging.usePublicVapidKey(
|
try {
|
||||||
// Project Settings => Cloud Messaging => Web Push certificates
|
messaging = firebase.messaging();
|
||||||
"BBlvtEL73vYinkiAgK5t51jgDTYj6961OO_5niP4Q5py_l5yhTL8IGYkpONyMGoXs8ZTdVhEWsu3_IEXcW0cIIg"
|
messaging.usePublicVapidKey(
|
||||||
);
|
// Project Settings => Cloud Messaging => Web Push certificates
|
||||||
|
"BBlvtEL73vYinkiAgK5t51jgDTYj6961OO_5niP4Q5py_l5yhTL8IGYkpONyMGoXs8ZTdVhEWsu3_IEXcW0cIIg"
|
||||||
|
);
|
||||||
|
console.log("Firebase Messaging initialized successfully.");
|
||||||
|
} catch {
|
||||||
|
console.log("Firebase Messaging is likely unsupported.");
|
||||||
|
}
|
||||||
|
|
||||||
export { messaging };
|
export { messaging };
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ export function register(config) {
|
|||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register("./firebase-messaging-sw.js")
|
.register("./firebase-messaging-sw.js")
|
||||||
.then(function (registration) {
|
.then(function (registration) {
|
||||||
console.log("FCM Registration :", registration);
|
|
||||||
console.log(
|
console.log(
|
||||||
"FCM Registration successful, scope is:",
|
"FCM Registration successful, scope is:",
|
||||||
registration.scope
|
registration.scope
|
||||||
|
|||||||
Reference in New Issue
Block a user