Software Archive
Read-only legacy content
17061 Discussions

NEED HELP with cordova-plugin-navis-background-geolocation

Andrejs_V_
Beginner
389 Views

Hello All!

I stopped with problem working with cordova-plugin-navis-background-geolocation .

I can build project for Android, but when I try init this object  window.plugin.backgroundGeoLocation I get undefined.

when I try search how to resolve problem , found only this two similar sites:

https://getsatisfaction.com/apperyio/topics/geolocation_plugin_problem

https://getsatisfaction.com/apperyio/topics/-tutorial-background-geolocation-plugin-installation

==========

It's hard to me correctly reflect to XDK specific .

====================

 

There need only one simple task:

after get app.ready

document.addEventListener("app.Ready", first_locate, false);

--------

function first_locate(){
    
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position){
              
      alert('Init ok');    
    }, function() {
      alert('Error ');     
      //handleLocationError(true, infoWindow, map.getCenter());
    },
    {enableHighAccuracy: true});
  } else {
    // Browser doesn't support Geolocation
     alert('Dont support ');   
    //handleLocationError(false, infoWindow, map.getCenter());
  }
 
  //var bgGeo = window.plugin.backgroundGeoLocation;
  var bgGeo = window.plugins.backgroundLocationServices;      
 

   if (typeof bgGeo === 'undefined') {
               alert('Plugin has not been initialized properly!', 'Error');
               //return false;
    }
           
         
   if (window.plugin.backgroundGeoLocation) {
             alert('Window.plugin.backg');
    }
        
    if (window.plugin.backgroundLocationServices) {
             alert('Window.plugin.Servisbackg');
    }   
   
}


====================================

get any alert message , or don't get 

Plugin has not been initialized properly! 

message .

=====================================

Any help are welcome!

Very need .....

========

All needed version for Android-sdk are OK

XDK 3522

Java SDK 1.08.101

all plugins from npm latest versions

framework F7

 

0 Kudos
2 Replies
PaulF_IntelCorp
Employee
389 Views

I'm guessing you're trying to use this plugin inside of the Simulate tab or in App Preview. It will only work in the Debug tab or in a built app.

Also, looking at the README and the sample app in that plugin repo it appears that the API interface is different. See the code in this sample > https://github.com/ivent/cordova-plugin-background-geolocation/blob/master/example/SampleApp/www/js/index.js < and notice that references are via an object named "backgroundGeoLocation" which would be inside window, not navigator.

I am speculating, I do not know that plugin and am guessing based on a very quick scan, you should take a closer look at the documentation and examples provided by the plugin developer.

0 Kudos
Andrejs_V_
Beginner
389 Views

Thank's for replay.

But: I build app to apk file and get alert that object not init properly.

Ok,  I'll test one more time for BackgroundGeoLocation object  ( there is so much forked plugin's :)  )

=======================

May I sound one wishes?

Background plugins for geolocations and for background task are very needed in common programming tasks - may Your team test and provide two plugins (geo and for tasks) as core plugins for XDK with testing and well know behaviour ?

For geolocation background may use this navis plugin (He builds fine w/o errors and works in Android and iOS)

 

 

 

 

 

0 Kudos
Reply