Offline Ride Tracking

OOSU Connect Driver: Full Offline Ride Tracking and Billing with Hive

Offline Ride-Sharing Revolution with OOSU Connect Driver: Full Offline Tracking & Billing Using Hive on Android & iOS 🚗💻

In India’s ride-sharing landscape, unreliable internet shouldn’t stop drivers from tracking rides, calculating distances, or generating bills. At Vantos, we built OOSU Connect Driver, a cutting-edge Android and iOS app powered by Flutter, Firebase Database, Hive, Google Maps, and Firebase Cloud Messaging (FCM). With a robust offline tracking solution using Hive, it ensures seamless ride management—from tracking to billing—without internet. Discover our technical journey and how OOSU Connect Driver can transform your ride-sharing business! 🌟

📞 Need an offline-first ride-sharing app? Contact Vantos at +91 82486 63599.

💬 Chat on WhatsApp

🔗 Download Now:(Googel Play Store)

The Challenge: Offline Barriers in Ride-Sharing

Low connectivity in semi-urban and rural India disrupts ride-sharing apps, causing:

  • Lost Trip Data: Offline tracking fails, breaking ride records.
  • Inaccurate Fares: Distance calculation errors lead to disputes.
  • Delayed Billing: No internet means no instant bills, frustrating drivers and passengers.
  • Missed Opportunities: Drivers lack real-time ride requests or admin guidance.

These issues cut driver earnings and erode customer trust. OOSU Connect Driver solves this with a full offline tracking solution using Hive, ensuring uninterrupted operations and smart features like admin messaging.

Our Solution: OOSU Connect Driver with Hive-Powered Offline Tracking

OOSU Connect Driver is a feature-packed app for Android and iOS, built with a modern tech stack:

  • Flutter: Cross-platform UI for consistent Android/iOS performance.
  • Firebase Database: Real-time syncing for ride requests and driver profiles.
  • Hive: Lightweight NoSQL database for full offline tracking, distance, and billing.
  • Google Maps: Precise location tracking and route optimization.
  • FCM: Instant push notifications for ride requests and admin alerts.

Key Features

  • Full Offline Tracking & Billing: Hive stores locations, distances, and fares offline, syncing when online.
  • OTP Verification: Secure driver login via Firebase SMS-based OTP.
  • 3 km Ride Request Notifications: Alerts drivers within 3 km of pickup locations.
  • Auto Ride Request Retry: Reassigns unaccepted requests to nearby drivers.
  • Auto Waiting Time Calculation: Tracks waiting periods for accurate fare adjustments.
  • Vehicle-Type Kilometer Charges: Custom rates for cars, autos, or bikes.
  • Monthly License Payment: In-app driver subscription payments.
  • Direct Fare Collection: Drivers collect fares directly from customers.
  • Admin Messaging System: Private or group FCM messages guide drivers to high-demand areas.
  • Admin Benefit: Admins analyze trip patterns and send FCM messages like, “Move to Place 2 for more trips!”—boosting driver earnings by 20–30%.

Technical Implementation: Building the Offline-First App

Here’s how we engineered OOSU Connect Driver to deliver a full offline tracking solution using Hive, with smart features for drivers and admins.

Set Up Flutter & Dependencies

Configured Flutter for Android/iOS and added dependencies in pubspec.yaml.

dependencies:
  flutter:
    sdk: flutter
  hive: ^2.2.3
  hive_flutter: ^1.1.0
  geolocator: ^9.0.2
  firebase_database: ^10.0.1
  firebase_auth: ^4.6.0
  firebase_messaging: ^14.6.0
  google_maps_flutter: ^2.2.0
  fluttertoast: ^8.2.2
  intl: ^0.17.0
  latlong2: ^0.8.1
  razorpay_flutter: ^1.3.4

dev_dependencies:
  hive_generator: ^2.0.0
  build_runner: ^2.3.3
Initialized Firebase, Google Maps API, and Razorpay for payments.

OTP Verification with Firebase Auth

Secured driver login with phone-based OTP, auto-retrieved on Android.
FirebaseAuth auth = FirebaseAuth.instance;
await auth.verifyPhoneNumber(
  phoneNumber: '+91${phoneController.text}',
  timeout: const Duration(seconds: 60),
  verificationCompleted: (PhoneAuthCredential credential) async {
    await auth.signInWithCredential(credential);
    Fluttertoast.showToast(msg: "Login Successful");
  },
  verificationFailed: (FirebaseAuthException e) {
    Fluttertoast.showToast(msg: "Error: ${e.message}");
  },
  codeSent: (String verificationId, int? resendToken) {
    setState(() => this.verificationId = verificationId);
  },
  codeAutoRetrievalTimeout: (String verificationId) {},
);

Hive Models for Offline Storage

Defined models like RideCompletionEntry for offline fare and distance data.
@HiveType(typeId: 3)
class RideCompletionEntry extends HiveObject {
  @HiveField(0) String rideRequestId;
  @HiveField(1) double? totalFareAmount;
  @HiveField(2) double? waitingCharge;
  @HiveField(5) double? waitingTimeMinutes;
  @HiveField(10) double? actualDistanceTraveled;
  @HiveField(11) String status;
  @HiveField(12) bool isSynced;

  RideCompletionEntry({
    required this.rideRequestId,
    required this.totalFareAmount,
    required this.waitingCharge,
    required this.waitingTimeMinutes,
    required this.actualDistanceTraveled,
    required this.status,
    this.isSynced = false,
  });
}
Generated adapters: flutter packages pub run build_runner build.

Initialize Hive & Firebase

Cleared legacy data and set up FCM for notifications.
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Hive.initFlutter();
  Hive.registerAdapter(RideCompletionEntryAdapter());
  await Hive.openBox<RideCompletionEntry>('ride_completion');
  await Hive.box<RideCompletionEntry>('ride_completion').clear();

  await Firebase.initializeApp();
  FirebaseMessaging messaging = FirebaseMessaging.instance;
  String? token = await messaging.getToken();
  print("FCM Token: $token");

  runApp(const OosuConnectDriverApp());
}

Full Offline Tracking with Hive

Stored waypoints, distances, and fares offline, syncing to Firebase when online.
void storeWaypoint(Position position) async {
  final waypointBox = Hive.box<WaypointEntry>('waypoints');
  double totalKM = waypointBox.values.last.totalKMTraveled ?? 0.0;
  totalKM += Geolocator.distanceBetween(
    last.latitude, last.longitude, position.latitude, position.longitude) / 1000.0;

  await waypointBox.add(WaypointEntry(
    rideRequestId: rideRequestId,
    latitude: position.latitude,
    longitude: position.longitude,
    totalKMTraveled: totalKM,
    isSynced: false,
  ));
}

Offline Billing with Hive

Generated fares offline and displayed in 5–10 seconds.
void completeTrip(double distance) async {
  final rideBox = Hive.box<RideCompletionEntry>('ride_completion');
  double fare = calculateFare(distance, vehicleType);
  final ride = RideCompletionEntry(
    rideRequestId: rideRequestId,
    totalFareAmount: fare,
    waitingCharge: waitingCharge,
    waitingTimeMinutes: waitingMinutes,
    actualDistanceTraveled: distance,
    status: 'completed',
    isSynced: false,
  );
  await rideBox.add(ride);
  showDialog(context: context, builder: (_) => FareAmountCollectionDialog(fare: fare));
}

3 km Ride Request Notifications

Sent FCM alerts to drivers within 3 km of pickup.
void sendRideRequestNotification(LatLng pickup, String rideId) async {
  final driverBox = Hive.box<DriverLocationEntry>('driver_locations');
  final nearbyDrivers = driverBox.values.where((d) {
    double distance = Geolocator.distanceBetween(
      pickup.latitude, pickup.longitude, d.latitude, d.longitude);
    return distance <= 3000;
  });
  for (var driver in nearbyDrivers) {
    await FirebaseMessaging.instance.sendMessage(
      to: driver.fcmToken,
      data: {'rideId': rideId, 'pickup': pickup.toString()},
      notification: Notification(title: "New Ride Request", body: "Pickup at $pickup"),
    );
  }
}

Auto Ride Request Retry

Retried unaccepted requests every 30 seconds.
void retryRideRequest(String rideId, LatLng pickup) async {
  Timer.periodic(Duration(seconds: 30), (timer) async {
    var ride = await FirebaseDatabase.instance.ref('rides/$rideId').get();
    if (ride.value['status'] == 'pending') {
      sendRideRequestNotification(pickup, rideId);
    } else {
      timer.cancel();
    }
  });
}

Auto Waiting Time Calculation

Tracked waiting periods for fare adjustments.
void startWaiting(Position position) async {
  final waitingBox = Hive.box<WaitingEntry>('waiting_times');
  final startTime = DateTime.now();
  final entry = WaitingEntry(
    rideRequestId: rideRequestId,
    startTimestamp: startTime.toIso8601String(),
    latitude: position.latitude,
    longitude: position.longitude,
  );
  await waitingBox.add(entry);
  Timer(Duration(minutes: 5), () {
    double minutes = DateTime.now().difference(startTime).inMinutes.toDouble();
    updateFare(minutes: minutes);
  });
}

Admin Messaging System(FCM)

Sent FCM messages to guide drivers.
void sendAdminMessage(String message, List<String> driverTokens) async {
  for (var token in driverTokens) {
    await FirebaseMessaging.instance.sendMessage(
      to: token,
      notification: Notification(title: "Admin Alert", body: message),
    );
  }
}

Solution Overview:

The company achieved an automated, end-to-end reporting solution by using Azure Data Factory (ADF) as the primary data integration service and Python for data transformation, cleaning, and report generation. This solution allowed for real-time data processing, seamless data flow, and comprehensive reporting capabilities, which helped the company maintain high standards and streamline its reporting process.

Solution Architecture

📞 Build your offline-first app with Vantos. Call

Why OOSU Connect Stands Out?

OOSU Connect Driver empowers drivers with offline reliability, automation, and admin insights, making it ideal for India’s diverse markets. Admins optimize fleets using trip data and FCM messaging, boosting efficiency. Built with Flutter’s cross-platform power, it’s scalable for global ride-sharing ventures.

📞 Ready to revolutionize your ride-sharing business? Contact Vantos at +91 82486 63599 or visit vantos.in.

Let’s Connect!

How do you tackle offline challenges in ride-sharing? Tried OOSU Connect Driver yet? Share your thoughts! 🚕 For custom app development, DM me or call +91 82486 63599.

Download OOSU Connect and join the offline-first revolution!

💬 Chat on WhatsApp

#OOSUConnect #OfflineTracking #RideSharing #FlutterDevelopment #Hive #Firebase #FCM #VantosIndia