feat: client monorepo (Flutter app) + web fallback redesign #1
@@ -1,14 +1,13 @@
|
|||||||
// Background handler for FCM web push. Keep the config in sync with
|
// Background handler for FCM web push. Keep the config in sync with
|
||||||
// window.KC_FIREBASE in index.html (a service worker can't read window).
|
// window.KC_FIREBASE in index.html (a service worker can't read window).
|
||||||
// Fill in apiKey / appId from the Firebase console before enabling push.
|
|
||||||
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js');
|
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js');
|
||||||
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js');
|
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js');
|
||||||
|
|
||||||
firebase.initializeApp({
|
firebase.initializeApp({
|
||||||
apiKey: 'REPLACE_ME',
|
apiKey: 'AIzaSyDxBpdmW8lUHSuix--3AsWJScGQy9o3G_M',
|
||||||
projectId: 'konfi-castle-app',
|
projectId: 'konfi-castle-app',
|
||||||
messagingSenderId: '307226979593',
|
messagingSenderId: '307226979593',
|
||||||
appId: 'REPLACE_ME',
|
appId: '1:307226979593:web:66898b2c78b2d110ef77d8',
|
||||||
});
|
});
|
||||||
|
|
||||||
firebase.messaging().onBackgroundMessage(function (payload) {
|
firebase.messaging().onBackgroundMessage(function (payload) {
|
||||||
|
|||||||
@@ -32,26 +32,27 @@
|
|||||||
<title>KC-App</title>
|
<title>KC-App</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
|
|
||||||
<!-- Firebase Cloud Messaging (web push). Fill in apiKey / appId / vapidKey
|
<!-- Firebase Cloud Messaging (web push). vapidKey still needs the Web Push
|
||||||
from the Firebase console (Project settings > General / Cloud Messaging).
|
certificate key pair (Project settings > Cloud Messaging > Web config).
|
||||||
Until then window.KC_FIREBASE.apiKey stays "REPLACE_ME" and
|
Until it's set kcGetPushToken() returns null and the app runs without
|
||||||
kcGetPushToken() returns null, so the app simply runs without push. -->
|
push. -->
|
||||||
<script src="https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js"></script>
|
<script src="https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js"></script>
|
||||||
<script src="https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js"></script>
|
<script src="https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js"></script>
|
||||||
<script>
|
<script>
|
||||||
window.KC_FIREBASE = {
|
window.KC_FIREBASE = {
|
||||||
apiKey: "REPLACE_ME",
|
apiKey: "AIzaSyDxBpdmW8lUHSuix--3AsWJScGQy9o3G_M",
|
||||||
authDomain: "konfi-castle-app.firebaseapp.com",
|
authDomain: "konfi-castle-app.firebaseapp.com",
|
||||||
projectId: "konfi-castle-app",
|
projectId: "konfi-castle-app",
|
||||||
storageBucket: "konfi-castle-app.firebasestorage.app",
|
storageBucket: "konfi-castle-app.firebasestorage.app",
|
||||||
messagingSenderId: "307226979593",
|
messagingSenderId: "307226979593",
|
||||||
appId: "REPLACE_ME",
|
appId: "1:307226979593:web:66898b2c78b2d110ef77d8",
|
||||||
|
measurementId: "G-NK8K5VV40D",
|
||||||
vapidKey: "REPLACE_ME"
|
vapidKey: "REPLACE_ME"
|
||||||
};
|
};
|
||||||
window.kcGetPushToken = async function () {
|
window.kcGetPushToken = async function () {
|
||||||
try {
|
try {
|
||||||
var cfg = window.KC_FIREBASE;
|
var cfg = window.KC_FIREBASE;
|
||||||
if (!cfg.apiKey || cfg.apiKey === "REPLACE_ME" || !("Notification" in window)) return null;
|
if (!cfg.vapidKey || cfg.vapidKey === "REPLACE_ME" || !("Notification" in window)) return null;
|
||||||
if (!firebase.apps.length) firebase.initializeApp(cfg);
|
if (!firebase.apps.length) firebase.initializeApp(cfg);
|
||||||
var permission = await Notification.requestPermission();
|
var permission = await Notification.requestPermission();
|
||||||
if (permission !== "granted") return null;
|
if (permission !== "granted") return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user