0.11.20 push w link
This commit is contained in:
@@ -7,12 +7,32 @@ self.addEventListener('push', function (event) {
|
||||
const data = JSON.parse(eventInfo);
|
||||
const head = data.head || 'New Notification 🕺🕺';
|
||||
const body = data.body || 'This is default content. Your notification didn\'t have one 🙄🙄';
|
||||
const icon = data.img || 'static/img/svg/Logo.svg';
|
||||
|
||||
let notificationOptions = {
|
||||
body: body,
|
||||
icon: icon,
|
||||
};
|
||||
if ('url' in data){
|
||||
notificationOptions['data'] = { url: data.url };
|
||||
notificationOptions['actions'] = [{action: "open_url", title: data.button_name}]
|
||||
}
|
||||
|
||||
// Keep the service worker alive until the notification is created.
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(head, {
|
||||
body: body,
|
||||
icon: 'static/img/svg/Logo.svg'
|
||||
})
|
||||
self.registration.showNotification(head, notificationOptions)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', function(event) {
|
||||
|
||||
switch(event.action){
|
||||
case 'open_url':
|
||||
clients.openWindow(event.notification.data.url);
|
||||
break;
|
||||
case 'any_other_action':
|
||||
clients.openWindow("https://www.example.com");
|
||||
break;
|
||||
}
|
||||
}
|
||||
, false);
|
||||
@@ -28,7 +28,7 @@
|
||||
<script>
|
||||
|
||||
{#var user_id = {{ user.id }}#}
|
||||
ws_url = `wss://{% get_ws_address %}/ws/socket-server/?user_id={{ user.id }}`;
|
||||
ws_url = `ws://{% get_ws_address %}/ws/socket-server/?user_id={{ user.id }}`;
|
||||
var chatSocket;
|
||||
init_ws()
|
||||
const beep = new Audio('/static/sounds/beep_2.mp3')
|
||||
|
||||
Reference in New Issue
Block a user