transistorsoft / cordova-background-geolocation-SampleApp

Cordova Background Geolocation Sample Application
https://www.transistorsoft.com/shop/products/cordova-background-geolocation
MIT License
122 stars 78 forks source link

geofences not getting added #78

Open pmalhotra1 opened 7 years ago

pmalhotra1 commented 7 years ago

configureBackgroundGeolocationForFirstTime() {

console.log("Configuring for first time!");
// 2. Listen to events
this.backgroundGeolocation.on('location', this.onLocation.bind(this));
this.backgroundGeolocation.on('heartbeat', this.onHeartBeat.bind(this));
this.backgroundGeolocation.on('motionchange', this.onMotionChange.bind(this));
this.backgroundGeolocation.on('geofence', this.onGeofence.bind(this));
//this.backgroundGeolocation.on('activitychange', this.onActivityChange.bind(this));
//this.backgroundGeolocation.on('background-fetch', this.onBackGroundFetch.bind(this));

// 3. Configure it.
this.backgroundGeolocation.configure(this.config, function(state)  {
  console.log('started ');
  this.backgroundGeolocation.addGeofences([{
    identifier: "Home",
    radius: 150,
    latitude: 45.51921926,
    longitude: -73.61678581,
    notifyOnEntry: true,
    notifyOnExit: false,
    notifyOnDwell: true,
    loiteringDelay: 30000,   // 30 seconds
    extras: {                // Optional arbitrary meta-data
      zone_id: 1234
    }
  }], function() {
    console.log("Successfully added geofence");
  }, function(error) {
    console.warn("Failed to add geofence", error);
  });

this.backgroundGeolocation.startGeofences(function(state) {
  console.log('- Geofence-only monitoring started', state.trackingMode);
    });
});  

} -----Issue--------

The only log I get is : "Configuring for first time!

after that I do not get the "Successfully added geofence" and "- Geofence-only monitoring started'"

Am I missing something ?