-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.qml
62 lines (53 loc) · 1.98 KB
/
main.qml
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
import QtQuick 2.2
import QtQuick.Controls 1.2
import com.cutehacks.notifications 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
NotificationReceiver {
id: notificationReceiver
gcmSenderId: "738724701239"
function showRequestInfo(text) {
console.log(text)
}
Component.onCompleted: {
init();
}
onGcmRegistrationIdChanged: {
console.log(gcmRegistrationId);
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
showRequestInfo("Headers -->");
showRequestInfo(req.getAllResponseHeaders ());
showRequestInfo("Last modified -->");
showRequestInfo(req.getResponseHeader ("Last-Modified"));
} else if (req.readyState == XMLHttpRequest.DONE) {
console.log(req.responseText);
var a = req.responseXML.documentElement;
for (var ii = 0; ii < a.childNodes.length; ++ii) {
showRequestInfo(a.childNodes[ii].nodeName);
}
showRequestInfo("Headers -->");
showRequestInfo(req.getAllResponseHeaders ());
showRequestInfo("Last modified -->");
showRequestInfo(req.getResponseHeader ("Last-Modified"));
}
}
var data = {
user: "user1",
type: "android",
token: gcmRegistrationId
};
req.open("POST", "http://192.168.0.7:8000/subscribe");
req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
req.send(JSON.stringify(data));
}
}
Text {
text: notificationReceiver.gcmRegistrationId
anchors.centerIn: parent
}
}