I’m working with Ionic2, Angular2 and Typescript in my project. When I install cordova-plugin-geofence (GitHub - cowbell/cordova-plugin-geofence: Geofencing plugin for cordova). Geofence is configured as follows:
App.ts
platform.ready().then(() => {
if (window.geofence === undefined) {
console.log('Geofence Plugin not found');
}else{
console.log('Geofence plugin found');
window.geofence.initialize();
const geofence = this.geofenceService.create({
longitude: -8.404015,
latitude: 43.339147,
});
this.geofenceService.addOrUpdate(geofence).then(function () {
console.log('Geofence successfully added');
}, function (reason) {
console.log('Adding geofence failed', reason);
});
}
});
HomePage.ts
window.geofence.onTransitionReceived = function (geofences) {
geofences.forEach(function (geo) {
console.log('Geofence transition detected', geo);
});
}
The service geofence.service.ts it was configured as tsubik’s ionic2 geofence example: https://github.com/tsubik/ionic2-geofence/blob/master/app/services/geofence-service.ts
No errors appear on console in all geofence configuration process but method window.geofence.onTransitionReceived() not log anything when geofence transitions happen.
What’s wrong? Thanks!