Skip to content

Commit

Permalink
Fixed missing messaging init in SW
Browse files Browse the repository at this point in the history
  • Loading branch information
luke- committed Oct 16, 2024
1 parent 3c29d34 commit 53a3b7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ public static function onServiceWorkerControllerInit($event): void
firebase.initializeApp({
messagingSenderId: "{$pushDriver->getSenderId()}",
projectId: "{$module->getConfigureForm()->getJsonParam('project_id')}",
appId: "{$module->getConfigureForm()->firebaseAppId}",
apiKey: "{$module->getConfigureForm()->firebaseApiKey}",
appId: "{$module->getConfigureForm()->firebaseAppId}"
});
// Initialize Firebase Cloud Messaging and get a reference to the service
const messaging = firebase.messaging();
JS;
}

Expand Down
4 changes: 4 additions & 0 deletions resources/js/humhub.firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ humhub.module('firebase', function (module, require, $) {
});
this.messaging = firebase.messaging();
}

this.messaging.onMessage((payload) => {
console.log('Suppressed push notification. App has already focus.', payload);
});
};

const afterServiceWorkerRegistration = function (registration) {
Expand Down

0 comments on commit 53a3b7b

Please sign in to comment.