Browse Source

@adding custom alarm..

halphass 7 years ago
parent
commit
9f98cfc95f
3 changed files with 16 additions and 4 deletions
  1. 1 0
      config.xml
  2. 15 4
      www/js/main.js
  3. BIN
      www/media/alarm.wav

+ 1 - 0
config.xml

@@ -30,4 +30,5 @@
         <variable name="SENDER_ID" value="667898382143" />
     </plugin>
     <plugin name="cordova-sqlite-storage" spec="~2.0.2" />
+    <plugin name="cordova-plugin-media" spec="~3.0.0" />
 </widget>

+ 15 - 4
www/js/main.js

@@ -829,6 +829,9 @@ function checkAndReset() {
     }
 };
 
+
+
+var my_media = {};
 function onDeviceReadyPush() {
     var push = PushNotification.init({
         android: {
@@ -850,19 +853,27 @@ function onDeviceReadyPush() {
         var url = "https://xm.bus.pm/api/d/c?device=" + registration.registrationId;
         $.get(url, function( data ) {
             console.log(JSON.stringify(data));
-            console.log(JSON.stringify(data));
-            // $(".hiddendiv").append('<li>REQ A2A: '+ data +'</li>');
         });
     });
 
     push.on('notification', function(data) {
+        my_media = new Media("/android_asset/www/media/alarm.wav",
+            // success callback
+            function () {
+                console.log("play(): Success");
+            },
+            // error callback
+            function (err) {
+                console.log("play(): Error: " + JSON.stringify(err));
+            }
+        );
+        my_media.play();
         console.log(JSON.stringify(data));
-        console.log(JSON.stringify(data));
+        alert(JSON.stringify(data));
     });
 
     push.on('error', function(e) {
         console.log(JSON.stringify(e));
-        console.log(JSON.stringify(e));
     });
 };
 

BIN
www/media/alarm.wav