To track a user's location, we need to write the code according to the platform. Xamarin.Essentials has methods for getting the location of a user in shared code, but it cannot be used in the background. To be able to use the code that we will write for each platform, we need to create an interface. For the ILocationRepository interface, there will be just one implementation that will be used on both platforms, whereas for the location tracking service, we will have one implementation for the iOS platform and one for the Android platform.
Go through the following steps to create the ILocationRepository interface:
- In the MeTracker project, create a new folder called Services.
- Create a new interface in the Services folder called ILocationTrackingService.
- In the interface, add a method called StartTracking, as shown in the following code:
public interface ILocationTrackingService
{
void...