Geofence not working in Ionic 4

I have followed the approach for implementing Geofence in Ionic 4:

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…

import { Geofence } from '@ionic-native/geofence/ngx';

constructor(private geofence: Geofence) {
      console.log('geofence plugin ready'),
        console.log('geo error', err);

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

      console.log('geofence added'),
      (err) =>{
        console.log('geofence failed to add')

Please do you have any suggestions for why it is not working? :slight_smile:

1 Like

I think it will not work in browser because it is only for devices. And about notifications, did you get any error about missing permissions for gps?

Yes I think so too… I deployed to an Android device and it seems like I got it working now with the fences. I used onTransitionReceived() to play specific sounds when entering a fence radius. But I still don’t get the notifications, which seems weird… I only get the errors above