I want to create a MAUI app in which we can track the live location of delivery person in real time .
Loading
I want to create a MAUI app in which we can track the live location of delivery person in real time .
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tuhin PaulRank #7 · 71.9K reputationPosted Jul 30, 2024, 10:04 AM EDT
Updating the Delivery Person's Location in Firebase
Once we have the delivery person's location, we need to update it in Firebase. We can use the
FirebaseDatabaseclass to achieve this.using Firebase.Database; namespace DeliveryTracker { public class DeliveryPersonLocation { private readonly FirebaseDatabase _database; public DeliveryPersonLocation() { _database = FirebaseDatabase.DefaultInstance; } public async Task UpdateLocation(Location location) { var reference = _database.GetReference("delivery_person_location"); await reference.SetValueAsync(new { latitude = location.Latitude, longitude = location.Longitude }); } } }Track the Delivery Person's Location in Real-time
we need to track the delivery person's location in real-time.
using Firebase.Database; namespace DeliveryTracker { public class DeliveryPersonLocation { private readonly FirebaseDatabase _database; public DeliveryPersonLocation() { _database = FirebaseDatabase.DefaultInstance; } public async Task TrackLocation() { var reference = _database.GetReference("delivery_person_location"); await reference.OnValueChangedAsync((snapshot) => { var location = snapshot.GetValue(); // Update the map with the new location UpdateMap(location); }); } private void UpdateMap(Location location) { // Update the map with the new location var map = new Map(); map.MoveToRegion(new MapSpan(new Position(location.Latitude, location.Longitude), 0.01, 0.01)); } } }Install the Firebase NuGet package in your MAUI project.
Tuhin PaulRank #7 · 71.9K reputationPosted Jul 30, 2024, 10:02 AM EDT
using Firebase; namespace DeliveryTracker { public partial class App : Application { public App() { InitializeComponent(); FirebaseApp.InitializeApp(); } } }Delivery Person's Location
We also need to get the delivery person's location. We can use the
Locationclass to achieve this.using Xamarin.Essentials; namespace DeliveryTracker { public class DeliveryPersonLocation { public async Task GetLocation() { var location = await Geolocation.GetLocationAsync(); return location; } } }Ashish Pandey180 reputationPosted Jul 31, 2024, 2:09 AM EDT
Thanks Tuhin for the solution,but can explain more clearly that how will it work.
Tuhin PaulRank #7 · 71.9K reputationPosted Jul 30, 2024, 9:56 AM EDT
To create a MAUI app that tracks the live location of a delivery person in real-time, we can use Firebase as our backend.
Rajeev KumarRank #1,334 · 1.3K reputationPosted Jul 31, 2024, 7:14 AM EDT
Here we can use Firebase as our backend.
Tuhin PaulRank #7 · 71.9K reputationPosted Jul 31, 2024, 12:41 PM EDT