As you can see from above, the iOSLocationManager can be instantiated by passing an instance of GpsFilters which would have inside it all the settings in relation to Accuracy, Type of tracking and soon. Then, to start monitoring the location updates, we need to call Start() and we need to pass a callback to receive these updates. Also, it is worth noting that we need to stop this monitoring once we finish using it. The iOSLocatoinManager creates an instance of the CLLocationManager and passes it an instance of the CCLocationManagerDelegate to receive these updates.

A simple implementation of the GpsFilter can be similar to the one below:

Another important thing to notice is that starting this iOSLocationManager from a background thread would not work. iOS expects the instantiation of any location updates listener to be on the main UI thread. Otherwise, we would not receive any updates. This can be done as follows:

private void StartIOSLocationManagerOnMainThread()
{
MonoTouch.UIKit.UIApplication.SharedApplication.Delegate.InvokeOnMainThread(
() => {
IOSLocationManager = new IOSLocationManager(GpsFilters);
IOSLocationManager.Start(UpdateLocationOniOS);
});
}
private void UpdateLocationOniOS(CLLocation location)
{
if (location != null && GpsInfoReceived != null)
{
// The following line sets up the GpsInfo in the way my application is expecting them
// this is because my Gps calculation and storing logic is the same across all platforms
var gpsInfo = GpsTranslator.GetGpsInfo(location, GpsFilters);
GpsInfoReceived(this, new GpsInfoEventArgs(gpsInfo));
}
}