2023-11-09 13:01:58 +05:30

80 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>BlazorWebassemblyPushNotification</title>
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png" />
<link href="BlazorWebassemblyPushNotification.Client.styles.css" rel="stylesheet" />
</head>
<body>
<div id="app">
<svg class="loading-progress">
<circle r="40%" cx="50%" cy="50%" />
<circle r="40%" cx="50%" cy="50%" />
</svg>
<div class="loading-progress-text"></div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.5.2/firebase-app.js";
// import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.5.2/firebase-analytics.js";
import { getMessaging, getToken } from "https://www.gstatic.com/firebasejs/10.5.2/firebase-messaging.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyAxAkj3yS3nY3i1qMmANohaOqKZBHNeqV4",
authDomain: "webapp-9ec9c.firebaseapp.com",
projectId: "webapp-9ec9c",
storageBucket: "webapp-9ec9c.appspot.com",
messagingSenderId: "363941055701",
appId: "1:363941055701:web:dde5972e1019d968e4e65c",
measurementId: "G-F4RT64WY6M"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
//const analytics = getAnalytics(app);
const messaging = getMessaging(app);
getToken(messaging, { vapidkey: "XIjWACWzSC4T1xajpuM0cV_OvAHTcPfobw_TsBCAHy8" }).then((currentToken) => {
if (currentToken) {
console.log("Token = " + currentToken);
} else {
console.log("no token found , need permision");
requestPermission()
}
}).catch((err) => {
console.log("a error occurrend while retrive the token " + err);
})
function requestPermission() {
console.log("requesting permission.....");
Notification.requestPermission().then((permission) => {
if (permission === "granted") {
console.log("Notification permission granted");
}
});
}
</script>
</body>
</html>