Location Delegate

In order to respond to the location manager events, you must implement the ISN_iCLLocationManagerDelegate , and set your delegate instance to the location manager using the SetDelegate method. See the sample delegate implementation below:

using UnityEngine;
using SA.iOS.CoreLocation;
using SA.Foundation.Templates;
using SA.iOS.UIKit;

public class ISN_CoreLocationDelegateExample : ISN_iCLLocationManagerDelegate
    public void DidChangeAuthorizationStatus(ISN_CLAuthorizationStatus authorizationStatus)
        ShowMessage("Authorization Status Changed", "CLAuthorizationStatus: " + authorizationStatus);

    public void DidUpdateLocations(ISN_CLLocationArray locations)
        var locationsInfo = string.Empty;
        foreach (var location in locations.Locations)
            locationsInfo += string.Format("Coordinate: Latitude - {0}, Longitude  - {1}",
            locationsInfo += "\n";
            //We will print rest of info as debug log:
            Debug.Log("location.Floor: " + location.Floor);
            Debug.Log("location.Speed: " + location.Speed);
            Debug.Log("location.Course: " + location.Course);
            Debug.Log("location.Altitude: " + location.Altitude);
            Debug.Log("location.Timestamp: " + location.Timestamp.ToString("yyyyMMddHHmmss"));
            Debug.Log("location.Coordinate.Latitude: " + location.Coordinate.Latitude);
            Debug.Log("location.Coordinate.Longitude: " + location.Coordinate.Longitude);
        ShowMessage("DidUpdateLocations ", locationsInfo);

    public void DidFailWithError(SA_Error error)
        ShowMessage("DidFailWithError ", error.FullMessage);

    public void DidFinishDeferredUpdatesWithError(SA_Error error)
        ShowMessage("DidFailWithError ", error.FullMessage);

    public void DidPauseLocationUpdates()
        ShowMessage("DidPauseLocationUpdates ", "DidPauseLocationUpdates event received");

    public void DidResumeLocationUpdates()
        ShowMessage("DidResumeLocationUpdates ", "DidResumeLocationUpdates event received");

    private void ShowMessage(string title, string message)
        var alert = new ISN_UIAlertController(title, message, ISN_UIAlertControllerStyle.Alert);
        var yesAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {});

And the example of how to set the delegate to the ISN_CLLocationManager

using SA.iOS.CoreLocation;

var @delegate = new ISN_CoreLocationDelegateExample();


The status parameter The new authorization status for the application.

This method is called whenever the application’s ability to use location services changes. Changes can occur because the user allowed or denied the use of location services for your application or for the system as a whole.

If the authorization status is already known when you call the RequestWhenInUseAuthorization or RequestAlwaysAuthorization method, the location manager does not report the current authorization status to this method. The location manager only reports changes to the authorization status. For example, it calls this method when the status changes from NotDetermined to AuthorizedWhenInUse.


Tells the delegate that new location data is available. The ISN_CLLocationArray parameter containing the location data. This array always contains at least one object representing the current location. If updates were deferred or if multiple locations arrived before they could be delivered, the array may contain additional entries. The objects in the array are organized in the order in which they occurred. Therefore, the most recent location update is at the end of the array.


Tells the delegate that the location manager was unable to retrieve a location value. The errorparam contains the reason the location or heading could not be retrieved. 

If you do not implement this method, Core Location throws an exception when attempting to use location services.

The location manager calls this method when it encounters an error trying to get the location or heading data. If the location service is unable to retrieve a location right away, it reports a kCLErrorLocationUnknown error and keeps trying. In such a situation, you can simply ignore the error and wait for a new event. If a heading could not be determined because of strong interference from nearby magnetic fields, this method returns kCLErrorHeadingFailure.

If the user denies your application’s use of the location service, this method reports a kCLErrorDenied error. Upon receiving such an error, you should stop the location service.


Tells the delegate that updates will no longer be deferred. The error param contains the reason deferred location updates could not be delivered. 

The location manager object calls this method to let you know that it has stopped deferring the delivery of location events. The manager may call this method for any number of reasons. For example, it calls it when you stop location updates altogether, when you ask the location manager to disallow deferred updates, or when a condition for deferring updates (such as exceeding a timeout or distance parameter) is met.


Tells the delegate that location updates were paused.

When the location manager detects that the device’s location is not changing, it can pause the delivery of updates in order to shut down the appropriate hardware and save power. When it does this, it calls this method to let your app know that this has happened.

After a pause occurs, it is your responsibility to restart location services again at an appropriate time. You might use your implementation of this method to start region monitoring at the user's current location or enable the visits location service to determine when the user starts moving again. Another alternative is to restart location services immediately with a reduced accuracy (which can save power) and then return to a greater accuracy only after the user starts moving again.


When you restart location services after an automatic pause, Core Location calls this method to notify your app that services have resumed. You are responsible for restarting location services in your app. Core Location does not resume updates automatically after it pauses them. For tips on how to restart location services when a pause occurs, see the discussion of the DidPauseLocationUpdates method describtion.