-
-
Save bkonyi/3dcbb962308582d6f7e8446c3f1c6994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class GeofencingPlugin { | |
static const MethodChannel _channel = | |
const MethodChannel('plugins.flutter.io/geofencing_plugin'); | |
static Future<bool> initialize() async { | |
final callback = PluginUtilities.getCallbackHandle(callbackDispatcher); | |
await _channel.invokeMethod('GeofencingPlugin.initializeService', | |
<dynamic>[callback.toRawHandle()]); | |
} | |
static Future<bool> registerGeofence( | |
GeofenceRegion region, | |
void Function(List<String> id, Location location, GeofenceEvent event) | |
callback) { | |
if (Platform.isIOS && | |
region.triggers.contains(GeofenceEvent.dwell) && | |
(region.triggers.length == 1)) { | |
throw UnsupportedError("iOS does not support 'GeofenceEvent.dwell'"); | |
} | |
final args = <dynamic>[ | |
PluginUtilities.getCallbackHandle(callback).toRawHandle() | |
]; | |
args.addAll(region._toArgs()); | |
_channel.invokeMethod('GeofencingPlugin.registerGeofence', args); | |
} | |
/* | |
* … `removeGeofence` methods here … | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment