geofencing_flutter_plugin 0.0.1-beta.1 geofencing_flutter_plugin: ^0.0.1-beta.1 copied to clipboard
The Woosmap Geofencing SDK is a mobile cross-platform software development kit focused on gathering efficiently the users location, triggering events based on region monitoring, and providing categori [...]
geofencing_flutter_plugin #
This react-native plugin extends the functionality offered by the Woosmap Geofencing Mobile SDKs. Find more about the Woosmap Geofencing SDK.
Android | iOS | |
---|---|---|
Support SDK | 33+ | 13.0+ |
Supported Platforms #
- iOS
- Android
Modules #
- GeofencingFlutterPlugin: Contains methods to monitor location, regions and POIs.
Objects(Read Only) #
- Location: Represents the location object
- POI: Represents Point of Interest
- Region: Represents a geographical region/geofence
Usage #
import 'package:geofencing_flutter_plugin/geofencing_flutter_plugin.dart';
final geofencingFlutterPlugin = GeofencingFlutterPlugin();
// ...
Check and request permissions #
Before initializing the SDK it is required that you request for required location permissions.
To check if the location permissions are granted by the user call getPermissionsStatus
method.
Future<String?> returnVal = geofencingFlutterPlugin.getPermissionsStatus();
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: ${error.message}');
});
Parameter status will be a string, one of:
GRANTED_BACKGROUND
: User has granted location access even when app is not running in the foreground.GRANTED_FOREGROUND
: Location access is granted only while user is using the app.DENIED
: Location access is denied.UNKNOWN
: Without providing or denying any permission then it will return unknown.
Please note: Plugin will not work as expected if location access is denied.
Requesting location access
To request location access call requestPermissions
method of the plugin. This will result in displaying location access permission dialog. This method accepts a boolean parameter background
. If this parameter is set to true, then plugin will ask for background location access. Code snippet below asks for background location access.
Future<String?> returnVal = geofencingFlutterPlugin.requestPermissions(background);
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: ${error.message}');
});
Initializing the plugin #
Plugin can be initialized by simply calling initialize
method.
Map<String, String> woosmapSettings = {
"privateKeyWoosmapAPI": "<<WOOSMAP_KEY>>",
"trackingProfile": "liveTracking"
};
Future<String?> returnVal = geofencingFlutterPlugin.initialize(woosmapSettings);
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: $error');
});
Both configuration options privateKeyWoosmapAPI
and trackingProfile
are optional. You can also initialize the plugin by passing null configuration.
Future<String?> returnVal = geofencingFlutterPlugin.initialize();
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: $error');
});
You can also set the Woosmap API key later by calling setWoosmapApiKey
method.
Future<String?> returnVal = geofencingFlutterPlugin.setWoosmapApiKey("<<WOOSMAP_KEY>>");
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: ${error.message}');
});
Tracking #
Once you have initialized the plugin and the user has authorized location permissions, you can start tracking the user’s location.
To start tracking, call:
Future<String?> returnVal = geofencingFlutterPlugin.startTracking('liveTracking');
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: ${error.message}');
});
To stop tracking, call:
Future<String?> returnVal = geofencingFlutterPlugin.stopTracking();
returnVal.then((value){
debugPrint(value!);
}).catchError((error) {
debugPrint('An error occurred: ${error.message}');
});
Method startTracking
accepts only following tracking profiles
- liveTracking
- passiveTracking
- visitsTracking
Tracking profile properties #
Property | liveTracking | passiveTracking | visitsTracking |
---|---|---|---|
trackingEnable | true | true | true |
foregroundLocationServiceEnable | true | false | false |
modeHighFrequencyLocation | true | false | false |
visitEnable | false | false | true |
classificationEnable | false | false | true |
minDurationVisitDisplay | null | null | 300 |
radiusDetectionClassifiedZOI | null | null | 50 |
distanceDetectionThresholdVisits | null | null | 25 |
currentLocationTimeFilter | 0 | 0 | 0 |
currentLocationDistanceFilter | 0 | 0 | 0 |
accuracyFilter | 100 | 100 | 100 |
searchAPIEnable | false | true | false |
searchAPICreationRegionEnable | false | true | false |
searchAPITimeFilter | 0 | 0 | 0 |
searchAPIDistanceFilter | 0 | 0 | 0 |
distanceAPIEnable | false | false | false |
modeDistance | null | null | null |
outOfTimeDelay | 300 | 300 | 300 |
DOUBLEOfDayDataDuration | 30 | 30 | 30 |
Getting Started #
This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.