Add notification sending functionality.

This commit is contained in:
Danila Fedorin 2018-12-12 00:03:17 -08:00
parent 00ba3a6ac0
commit 3e7d12b6e4
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,11 @@
port module Scylla.Notification exposing (..)
import Scylla.Model exposing (..)
import Json.Decode
type alias Notification =
{ name : String
, text : String
}
port sendNotificationPort : Notification -> Cmd msg
port onNotificationClockPort : (Json.Decode.Value -> msg) -> Sub msg

View File

@ -0,0 +1,12 @@
if("Notification" in window) {
Notification.requestPermission();
}
function setupNotificationPorts(app) {
app.ports.sendNotificationPort.subscribe(function(data) {
var options = {
"body" : data.text
}
new Notification(data.name, options)
})
}