0
Hello, I’ve been asked to use Chrome’s native Notification (API) to display a notification to the user as soon as they enter the system (I know I could use other modes, but I’ve been asked to use this).
- This notification is created in JS and makes a request in PHP that returns data from a query.
- The file I consult is the notification-point-query.php which appears in the code shown just below.
I wonder if it is possible to style this Window that is opened. I would like to, for example, change the background-color, color, font-size, among others...
Do you know if this is possible ? I searched hard, but found nothing talking about it.
Below is the code I use to create this notification window:
$(document).ready(function() {
let chamar = minhaNotificacao();
});
document.addEventListener('DOMContentLoaded', function() {
if (!Notification) {
alert("As notificações no desktop não estão disponíveis para o seu navegador. Tente o Chrome");
return;
}
if (Notification.permission !== "granted") {
Notification.requestPermission();
}
});
function minhaNotificacao() {
if (Notification.permission !== "granted") {
Notification.requestPermission();
} else {
$.ajax({
url: "../banco/notificacoes-pontuais/notificacoes-pontuais-consulta.php",
data: {
fonte: 'aocarregar'
},
type: "POST",
async: true
}).done(function(data) {
var notification = new Notification('Notificação diária', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: 'Você possui: \nLembretes de eventos para hoje: ' + data.eventos_lembretes + '\nLembretes de Tarefas: ' + data.eventos_tarefas + '\nEventos Vencidos: ' + data.eventos_vencidos,
});
}
}
Below, I show how the notification appears when called:
Thank you!
Please, dear downvoter, show me where I went wrong on this question so maybe I can improve it or improve my next.
– Gato de Schrödinger