I have followed the approach for implementing Geofence in Ionic 4: https://ionicframework.com/docs/native/geofence
When run in the browser with ‘ionic cordova run browser’ I get the following in the console:
Ionic Native: deviceready event fired after 537 ms
Error: exec proxy not found for :: GeofencePlugin :: deviceReady
Error: exec proxy not found for :: GeofencePlugin :: initialize
Error: exec proxy not found for :: GeofencePlugin :: addOrUpdate
ERROR Error: Uncaught (in promise): Missing Command Error
Unhandled Promise rejection: Missing Command Error ; Zone: ; Task: null ; Value: Missing Command Error
I don’t know if these are real errors or just because I need to run it on a device.
I have also deployed to Android and when running on android with ‘ionic cordova run android’ everything seems to run fine, but I get no notifications from the Geofencing and I can’t see if I get any errors…
Home.page.ts
import { Geofence } from '@ionic-native/geofence/ngx';
constructor(private geofence: Geofence) {
geofence.initialize().then(()=>{
console.log('geofence plugin ready'),
(err)=>{
console.log('geo error', err);
}
});
this.addGeoFence();
}
private addGeofence(){
let fence ={
id: '69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb',
latitude: 55.663102,
longitude: 12.590352,
radius: 100,
transitionType: 3,
notification: {
id: 1,
title: 'You crossed a sight',
text: 'You just arrived',
vibrate: [2000],
openAppOnClick: true
}
}
this.geofence.addOrUpdate(fence).then(()=>{
console.log('geofence added'),
(err) =>{
console.log('geofence failed to add')
}
});
}
Please do you have any suggestions for why it is not working?