TF-1246: Enable FCM for Web browser

This commit is contained in:
ManhNTX
2022-11-29 20:11:15 +07:00
committed by Dat H. Pham
parent d990426c8e
commit 045c7383e6
7 changed files with 45 additions and 5 deletions
+13
View File
@@ -0,0 +1,13 @@
importScripts("https://www.gstatic.com/firebasejs/9.10.0/firebase-app-compat.js");
importScripts("https://www.gstatic.com/firebasejs/9.10.0/firebase-messaging-compat.js");
firebase.initializeApp({
apiKey: "...",
authDomain: "...",
databaseURL: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "...",
});
const messaging = firebase.messaging();
+1
View File
@@ -56,6 +56,7 @@
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
navigator.serviceWorker.register('firebase-messaging-sw.js');
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {