Add notification support for cellphone

This commit is contained in:
2023-11-07 22:13:33 +01:00
parent 467ad7a297
commit 62c0ce6c17
2 changed files with 11 additions and 0 deletions

View File

@@ -48,5 +48,11 @@ function newGoalAlert(match, goalTeam){
</div>
`
alertsContainer.insertAdjacentHTML("beforeend", alert)
//Send a notification to the client if the browser supports it
if (Notification.permission === "granted") {
let notification = new Notification(`${match.expand.team1.name} - ${match.expand.team2.name}`, {
body: `${match.point1} - ${match.point2}`,
});
}
setTimeout(deleteAlert, 5000, `${match.id}${match.point1}_${match.point2}`)
}

View File

@@ -6,6 +6,11 @@ let matchList = await pb.collection('match').getFullList({
expand: 'team1,team2,sport',
});
//Ask for notifications permission
if (Notification.permission !== "granted") {
Notification.requestPermission();
}
const equipeList = await pb.collection('equipes').getFullList({});
const sportList = await pb.collection('sport').getFullList({});