-
Notifications
You must be signed in to change notification settings - Fork 1
/
receiver.html
75 lines (67 loc) · 3.22 KB
/
receiver.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Firebase</title>
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="components/css/materialize.min.css" media="screen,projection" />
<link href="components/css/style.css" rel="stylesheet" type="text/css">
<script src="https://www.gstatic.com/firebasejs/3.7.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.4/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.4/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.4/firebase-messaging.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.4/firebase.js"></script>
<script>
//Initialise Service workers
if ('serviceWorker' in navigator) {
// Register service worker
navigator.serviceWorker.register('service-worker.js').then(function (reg) {
console.log("SW registration succeeded. Scope is " + reg.scope);
}).catch(function (err) {
console.error("SW registration failed with error " + err);
});
}
// Initialize Firebase
var config = {
apiKey: "<FIREBASE-SERVER-KEY>", //Firebase Server key.Found under "Cloud Messaging Tab"
authDomain: "<PROJECT-ID>.firebaseapp.com", //Firebase Project ID. ex: webpush-3460x
databaseURL: "https://<PROJECT-ID>.firebaseio.com/",
storageBucket: "gs://<PROJECT-ID>.appspot.com/",
messagingSenderId: "<SENDER-ID>", //Firebase Project Sender ID ex:204146733640
};
firebase.initializeApp(config);
</script>
<link rel="manifest" href="manifest.json">
</head>
<body>
<div class="row style">
<div class="input-field col s8">
<h5>Token ID:</h5>
<div id="divToken" style="display: none;"></div>
<p id="token" style="word-break: break-all;"></p>
<button class="btn waves-effect waves-light"
onclick="deleteToken()">
Reset Token<i class="material-icons right">repeat</i>
</button>
</div>
</div>
<div class="row style">
<div class="input-field col s12">
<div id="permission_div" style="display: none;">
<h4>Requires Permission</h4>
<p id="token"></p>
<button class="btn waves-effect waves-light"
onclick="requestPermission()">
Request Permission
</button>
</div>
</div>
</div>
<!-- Display Incoming notifications -->
<div class="row style">
<div class="input-field col s12">
<div id="messages"></div>
</div>
</div>
<script type="text/javascript" src="generate-token.js"></script>
</body>
</html>