2 Replies Latest reply on Sep 13, 2017 6:41 AM by blgsyrmhnds

    Ajax call does not work when open google maps app in my app

    blgsyrmhnds Level 1

         I'm developing a simple app with phonegap which every 30 seconds send user current coordinates to my database via ajax call.It works very well

       

      $(document).ready(function() {
        setInterval
      (function() {
        
      SetLocationUpdates();
        
      }, 30000);
        
      });

       

       

      If the app is in the foreground there is no problem and everything works fine, but if I open google maps app with this code

       

      <div><a href="geo:41.897096,27.036545">Open maps app</div>

       

       

      My app goes in the background(my app and google map app work separately.Two apps work at same time) and the interval function is not executed any more.

      Is it possible to have the javascript code (a timer function) executing in the background with phonegap?

       

      I use cordova-plugin-background-mode(https://github.com/katzer/cordova-plugin-background-mode) but it still does not work.And alert give false.What is wrong with this?

       

       

      document.addEventListener('deviceready', function () {

        cordova
      .plugins.backgroundMode.enable();
        alert
      (cordova.plugins.backgroundMode.isActive());
      }, false);

       

      Only ajax call does not work.In my app I open google maps.Two apps(my app and google map app) work.I play horse voice  and call ajax call every 5 second for testing.Playing horse voice work but ajax call does not work.I used timer or webworkers but it does not work anymore.

       

      SetLocationUpdates() send user current position to my database via ajax call

       

      work.onmessage = function(event) {

               

      var x = document.getElementById("myAudio");

      x.play();

      SetLocationUpdates();

              };