Develop Javascript Notification - aliconnect/aliconnect.sdk GitHub Wiki
Introductie
<!DOCTYPE html>
<html>
<head>
<title>Notification
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/lib/css/aim.css" />
<link rel="stylesheet" href="/lib/css/icon.css" />
<script type="text/javascript" charset="UTF-8" src="https://aliconnect.nl/api/js">
<script type="text/javascript" charset="UTF-8" src="/lib/js/aim.js">
<script type="text/javascript" charset="UTF-8" src="/lib/js/app.js">
<body class="row aim om bg" view="rows">
<div id="navtop" class="row top bar noselect np">
<nav id="navleft" class="col aco noselect np">
<div class="seperator noselect">
<nav id="navtree" class="col aco atv noselect np">
<div class="noselect seperator">
<div id="collist" class="row aco alv">
<div right class="noselect seperator">
<div id="colpage" class="col aco apv printcol">
<button id="notification1">Notification 1 from this app
<button id="notification2">Notification 2 from this app, actions
<div id="colinfo" class="col apv ainf">
<div id="rowinfo"><div id="statusbar">
<div id="colpanel" class="col pupanel shdw">
<iframe id="baseframe" name="baseframe" class="col " style="display:none;">
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/lib/js/sw.js', { scope: '/' })
.then(function(registration) {
console.log('Registration successful, scope is:', registration.scope);
navigator.serviceWorker
})
.catch(function(error) {
console.log('Service worker registration failed, error:', error);
});
}
Notification.requestPermission(function(result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function(registration) {
console.log('navigator.serviceWorker', registration);
});
}
});
notification1.onclick = function(e) {
new AIM.Notification({
Title:'Notification 1',
url: document.location.href,
options: {
icon: '',
image: '',
lang: 'nl-NL',
tag: 1,
body: 'This is a message to you. Please check your application for more details',
},
});
}
notification2.onclick = function(e) {
fetch ('test', {credentials: 'include'});
// registration.showNotification('Vibration Sample', {
// actions: [
// { action:'accept', title:'Accept request', icon:'' },
// { action:'deny', title:'Deny request', icon:'' },
// ],
// body: 'Buzz! Buzz!',
// icon: '../images/touch/chrome-touch-icon-192x192.png',
// vibrate: [200, 100, 200, 100, 200, 100, 200],
// tag: 'vibration-sample'
// });
//
return;
new AIM.Notification({
Title:'Notification 2',
url: document.location.href,
options: {
actions: [
{ action:'accept', title:'Accept request', icon:'' },
{ action:'deny', title:'Deny request', icon:'' },
],
icon: '',
image: '',
lang: 'nl-NL',
tag: 2,
body: 'This is a message to you. Please check your application for more details',
},
});
}