API Reference
API Reference

Moca supports both foreground and background callbacks to handle events (such as geofence triggers, beacon detection, or errors).

  1. onGeofence(RegionCallback? callback)
    Registers a callback to be invoked on geofence enter and exit events
    Parameters:

    • callback: RegionCallback, optional – A function that takes a String verb ('enter' or 'exit') and a Map (region details).
      Example:
    Moca.onGeofence((verb, region) {
      print("Geofence event: " + verb + ", details: " + region.toString());
    });
    
  2. onBeacon(RegionCallback? callback)
    Registers a callback to be invoked on beacon events.
    Parameters:

    • callback: RegionCallback, optional – A function that takes a String verb and a Map (beacon details).
  3. onRegionGroup(RegionCallback? callback)
    Registers a callback for region group events.
    Parameters:

    • callback: RegionCallback, optional – A function that takes a String verb and a Map (region group details).
  4. onError(ErrorCallback? callback)
    Registers a callback to handle errors from the plugin.
    Parameters:

    • callback: ErrorCallback, optional – A function that takes a Map representing an error event.