Closed Naapperas closed 1 year ago
Great question! The Flutter SDK does already support foreground and background tracking, but in order to see the events, you must do the following:
Request foreground and then background location permissions (see line 100 in the example app's main.dart
):
// status will be one of GRANTED_FOREGROUND, GRANTED_BACKGROUND, or DENIED
var status = await Radar.requestPermissions(false);
if (status == 'GRANTED_FOREGROUND') {
status = await Radar.requestPermissions(true);
}
Start background tracking (line 55 in main.dart
):
Radar.startTracking('responsive');
Listen for events (line 24 in main.dart
):
Radar.onEvents((result) {
print('onEvents: $result');
});
Is this what you need? I'll file a ticket to make this clearer in the documentation. The docs don't discuss listeners like Radar.onEvents()
and Radar.onLocation()
, for example.
from what I could see in the official documentation, background tracking regarding geofencing is only present on Android and iOS
Can you point out where you read this?
Great question! The Flutter SDK does already support foreground and background tracking, but in order to see the events, you must do the following:
1. [Request foreground _and then_ background location permissions](https://radar.com/documentation/sdk/flutter#request-permissions) (see [line 100 in the example app's `main.dart`](https://github.com/radarlabs/flutter-radar/blob/3e41da909e3fa4239b8e5dae073903066c287cb3/example/lib/main.dart#L100)): ``` // status will be one of GRANTED_FOREGROUND, GRANTED_BACKGROUND, or DENIED var status = await Radar.requestPermissions(false); if (status == 'GRANTED_FOREGROUND') { status = await Radar.requestPermissions(true); } ``` 2. [Start background tracking](https://radar.com/documentation/sdk/flutter#background-tracking) ([line 55 in `main.dart`](https://github.com/radarlabs/flutter-radar/blob/3e41da909e3fa4239b8e5dae073903066c287cb3/example/lib/main.dart#L55)): ``` Radar.startTracking('responsive'); ``` 3. Listen for events ([line 24 in `main.dart`](url)): ``` Radar.onEvents((result) { print('onEvents: $result'); }); ```
Is this what you need? I'll file a ticket to make this clearer in the documentation. The docs don't discuss listeners like
Radar.onEvents()
andRadar.onLocation()
, for example.from what I could see in the official documentation, background tracking regarding geofencing is only present on Android and iOS
Can you point out where you read this?
Both the iOS and Android SDK References have a sub-section named Background tracking for geofencing while the Flutter one only has Background tracking. I assumed it did not include geofencing but it seems it was a misunderstanding on my part, I apologize.
Regarding the rest, it is in fact what I needed, thank you for pointing me in the right direction.
No apology needed! I can see how that could be confusing. I'll pass that feedback on to the team.
I'm glad that this helped!
Any plans on a Flutter SDK update regarding the geofencing capabilities already present in the Android/iOS SDKs ? The plugin itself seems amazing for geofencing (my particular use case) but, from what I could see in the official documentation, background tracking regarding geofencing is only present on Android and iOS. There could be fixes around this problem with events but there is also no documentation about those in the Flutter SDK docs. Is this going to be a feature or is it on hold/not planned ?