initiateTripMonitoring method
Initiates trip monitoring functionality in the Kruzr SDK.
This method sets up the necessary components for automatic trip detection and monitoring. Once initiated, the SDK will automatically detect when trips start and end based on vehicle movement patterns.
Prerequisites:
- initializeSDK must be called first
- Location permissions must be granted
- User should be logged in for optimal functionality
Usage:
try {
await communicator.initiateTripMonitoring();
print('Trip monitoring initiated successfully');
} catch (e) {
print('Failed to initiate trip monitoring: $e');
}
Throws:
Future.error("Unable to initiate trip monitoring"): When initialization fails
Important Notes:
- This enables automatic trip detection
- Requires appropriate device permissions
- Should be called after user login for best results
Implementation
Future<void> initiateTripMonitoring() async {
try {
await kruzr_comm.initiateTripMonitoring();
} on PlatformException catch (e) {
if (kDebugMode) {
print(e);
print("PlatformException in initiateTripMonitoring");
}
return Future.error("Unable to initiate trip monitoring");
} on Exception catch (e) {
if (kDebugMode) {
print(e);
print("Exception in initiateTripMonitoring");
}
return Future.error("Unable to initiate trip monitoring");
}
}