|
@@ -832,6 +832,11 @@ function checkAndReset() {
|
|
|
|
|
|
|
|
|
|
var my_media = {};
|
|
var my_media = {};
|
|
|
|
+function spengimi() {
|
|
|
|
+ my_media.stop();
|
|
|
|
+ $("#alert-title").hide();
|
|
|
|
+
|
|
|
|
+}
|
|
function onDeviceReadyPush() {
|
|
function onDeviceReadyPush() {
|
|
var push = PushNotification.init({
|
|
var push = PushNotification.init({
|
|
android: {
|
|
android: {
|
|
@@ -848,15 +853,43 @@ function onDeviceReadyPush() {
|
|
windows: {}
|
|
windows: {}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * registra l'id univoco dell'installazione su xm.bus.pm
|
|
|
|
+ */
|
|
push.on('registration', function(registration) {
|
|
push.on('registration', function(registration) {
|
|
- // console.log(JSON.stringify(registration));
|
|
|
|
|
|
+ console.log(JSON.stringify(registration));
|
|
var url = "https://xm.bus.pm/api/d/c?device=" + registration.registrationId;
|
|
var url = "https://xm.bus.pm/api/d/c?device=" + registration.registrationId;
|
|
$.get(url, function( data ) {
|
|
$.get(url, function( data ) {
|
|
console.log(JSON.stringify(data));
|
|
console.log(JSON.stringify(data));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * gestisce la notifica ricevuta
|
|
|
|
+ */
|
|
push.on('notification', function(data) {
|
|
push.on('notification', function(data) {
|
|
|
|
+ // console.log(JSON.stringify(data));
|
|
|
|
+ // alert(JSON.stringify(data));
|
|
|
|
+ /*
|
|
|
|
+ {
|
|
|
|
+ "title": "ciaooo",
|
|
|
|
+ "message": "ciaone",
|
|
|
|
+ "additionalData": {
|
|
|
|
+ "google.message_id": "0:1489146072171053%91acc10daee52ff4",
|
|
|
|
+ "coldstart": false,
|
|
|
|
+ "collapse_key": "ciaooo",
|
|
|
|
+ "foreground": true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ $("body").pagecontainer("change", "#alert");
|
|
|
|
+ $("#alert-title").html(data.title);
|
|
|
|
+ $("#alert-message").html(data.message);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * suona l'allarme
|
|
|
|
+ */
|
|
my_media = new Media("/android_asset/www/media/alarm.wav",
|
|
my_media = new Media("/android_asset/www/media/alarm.wav",
|
|
// success callback
|
|
// success callback
|
|
function () {
|
|
function () {
|
|
@@ -868,8 +901,6 @@ function onDeviceReadyPush() {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
my_media.play();
|
|
my_media.play();
|
|
- console.log(JSON.stringify(data));
|
|
|
|
- alert(JSON.stringify(data));
|
|
|
|
});
|
|
});
|
|
|
|
|
|
push.on('error', function(e) {
|
|
push.on('error', function(e) {
|