This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
/
index.html
81 lines (67 loc) · 2.19 KB
/
index.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
76
77
78
79
80
81
<!DOCTYPE HTML>
<html>
<head>
<title>Demo</title>
</head>
<body>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery_1.5.2.min.js"></script>
<script type="text/javascript">
function onDeviceReady() {
var pushConfig = {
pushServerURL: "<pushServerURL e.g http(s)//host:port/context >",
alias: "<alias e.g. a username or an email address optional>",
android: {
senderID: "<senderID e.g Google Project ID only for android>",
variantID: "<variantID e.g. 1234456-234320>",
variantSecret: "<variantSecret e.g. 1234456-234320>"
},
ios: {
variantID: "<variantID e.g. 1234456-234320>",
variantSecret: "<variantSecret e.g. 1234456-234320>"
}
};
var statusList = $("#app-status-ul");
statusList.append('<li>deviceready event received</li>');
try {
statusList.append('<li>registering </li>');
push.register(onNotification, successHandler, errorHandler, pushConfig);
} catch (err) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
alert(txt);
}
}
function onNotification(e) {
var statusList = $("#app-status-ul");
// on android we could play the sound, if we add the Media plugin
if (e.sound && (typeof Media != 'undefined')) {
var media = new Media("/android_asset/www/" + e.sound + '.wav');
media.play();
}
if (e.coldstart) {
statusList.append('<li>--COLDSTART NOTIFICATION--' + '</li>');
}
statusList.append('<li>MESSAGE -> MSG: ' + e.alert + '</li>');
//only on ios
if (e.badge) {
push.setApplicationIconBadgeNumber(successHandler, e.badge);
}
}
function successHandler() {
$("#app-status-ul").append('<li>success</li>');
}
function errorHandler(error) {
$("#app-status-ul").append('<li>error:' + error + '</li>');
}
document.addEventListener('deviceready', onDeviceReady, true);
</script>
<div id="home">
<div id="app-status-div">
<ul id="app-status-ul">
<li>AeroGear PushPlugin Unified Push Demo</li>
</ul>
</div>
</div>
</body>
</html>