Skip to content

Commit

Permalink
Improve conditions for service worker installation for browsers with …
Browse files Browse the repository at this point in the history
…no push support

Also update Firebase SDK
  • Loading branch information
paulincai committed Jun 11, 2020
1 parent 422e132 commit da764b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/client/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class WebPushHandle extends EventState {
// Otherwise register '/firebase-messaging-sw.js' which includes the sw.js

pushSupported = firebase.messaging.isSupported()

noConfiguration = !configuration.firebase || !configuration.publicVapidKey
const swSupported = 'serviceWorker' in navigator
const doTabsRefresh = () => {
Expand All @@ -64,11 +65,11 @@ class WebPushHandle extends EventState {
}

if (swSupported && !isFacebookApp()) {
if (noConfiguration) {
if (noConfiguration || !pushSupported) {
this.log('Firebase configuration is required: \'messagingSenderId\' and a \'PublicVapidKey\'')
navigator.serviceWorker.register('/sw.js')
.then(registration => {
// console.log('SW')
console.log('sw-basic')
})
.catch(err => {
console.log('ServiceWorker registration failed: ', err)
Expand All @@ -77,7 +78,7 @@ class WebPushHandle extends EventState {
return false
}

if (pushSupported) {
if (!noConfiguration && pushSupported) {
const webApp = firebase.initializeApp(configuration.firebase)
deviceStorage.setItem('pushSupport', true)

Expand Down
4 changes: 2 additions & 2 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* globals Package, Npm, Cordova */
Package.describe({
name: 'activitree:push',
version: '2.0.6',
version: '2.0.7',
summary: 'Push Notifications for Cordova and Web/PWA with Firebase (FCM).',
git: 'https://github.com/activitree/meteor-push.git'
})

Npm.depends({
'firebase-admin': '8.12.1',
firebase: '7.14.5'
firebase: '7.15.0'
})

Cordova.depends({
Expand Down

0 comments on commit da764b1

Please sign in to comment.