11. Notification
var mailNotification = new Notification("Bogdan Rusinka", {
tag : "cute-mail",
body : "Hi, look at that cutie!",
icon : "https://www.royalcanin.com/~/media/Royal-Canin/Product-Categories/dog-maxi-landing-
hero.ashx"
});
13. Official documentation
The Push API enables sending of a push message to a webapp via a push service.
An application server can send a push message at any time, even when a webapp
or user agent is inactive. The push service ensures reliable and efficient delivery
to the user agent. Push messages are delivered to a Service Worker that runs in
the origin of the webapp, which can use the information in the message to
update local state or display a notification to the user.
15. Be Aware
HTTPS required Because Service Workers can expose man-in-the-middle attacks in an unsecured
system, they can only be registered on an HTTPS enabled domain.
Service Workers, Notification, and Push APIs must all be supported
Push Messaging service: Messages must be routed through a messaging service, such as Google Cloud
Messaging (GCM) service
19. Inside service worker
self.addEventListener('push', function(event) {
console.log('Received a push message', event);
var title = 'Yay a message.';
var body = 'We have received a push message.';
var icon = '/images/icon-192x192.png';
var tag = 'simple-push-demo-notification-tag';
event.waitUntil(
self.registration.showNotification(title, {
body: body,
icon: icon,
tag: tag
})
);
});
32. How to use it?
window.navigator.vibrate(1000);
window.navigator.vibrate([3000, 2000, 1000]);
window.navigator.vibrate (0);
window.navigator.vibrate ([]);
38. Events
❖ chargingchange — the device has changed from being charged to being discharged or vice
versa
❖ levelchange — the battery level has changed
❖ chargingtimechange — the time until the battery is fully charged has changed
❖ dischargingtimechange — the time until the battery is fully discharged has changed
45. Motion angles
alpha the direction the device is facing according to the compass
beta the angle in degrees the device is tilted front-to-back
gamma the angle in degrees the device is tilted left-to-right.
57. Web speech API usage
var recognition = new webkitSpeechRecognition();
recognition.continuous
recognition.interimResults
recognition.onstart
recognition.onresult
recognition.onerror
recognition.onend
61. Capturing audio and video history
<input type="file" accept="image/*;capture=camera">
input type="file" accept="video/*;capture=camcorder">
<input type="file" accept="audio/*;capture=microphone">
63. WebRTC
This document defines a set of ECMAScript APIs in WebIDL to allow media to be sent to and received
from another browser or device implementing the appropriate set of real-time protocols.
64. A little bit love code
<video autoplay></video>
<script>
var onFail = function(e) {};
navigator.getUserMedia('video, audio', function(localMediaStream) {
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(localMediaStream);
video.onloadedmetadata = function(e) {
};
}, onFail);
</script>
78. Benefits
It is persistent: Pointer lock does not release the mouse until an explicit API call is made or the user
uses a specific release gesture.
It is not limited by browser or screen boundaries.
It continues to send events regardless of mouse button state.
It hides the cursor.