Geofence/Geofence/Geofence.Plugin.iOS/GeofenceImplementation.cs
/// <summary>
/// Checks if is available for monitoring
/// </summary>
/// <returns></returns>
Checks if is available for monitoring
Checks if is available for monitoring
public bool AvailableForMonitoring()
        {
            bool retVal = false;
            RequestAlwaysAuthorization();
            if (!CLLocationManager.LocationServicesEnabled)
            {
                string message = string.Format("{0} - {1}", CrossGeofence.Id, "You need to enable Location Services");
                System.Diagnostics.Debug.WriteLine(message);
                CrossGeofence.GeofenceListener.OnError(message);
            }
            else if (CLLocationManager.Status == CLAuthorizationStatus.Denied || CLLocationManager.Status == CLAuthorizationStatus.Restricted)
            {
                string message = string.Format("{0} - {1}", CrossGeofence.Id, "You need to authorize Location Services");
                System.Diagnostics.Debug.WriteLine(message);
                CrossGeofence.GeofenceListener.OnError(message);
            }
            else if (CLLocationManager.IsMonitoringAvailable(typeof(CLRegion)))
            {
                var settings = UIUserNotificationSettings.GetSettingsForTypes(
                  UIUserNotificationType.Alert
                  | UIUserNotificationType.Badge
                  | UIUserNotificationType.Sound,
                  new NSSet());
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                retVal = true;
            }
            else
            {
                string message = string.Format("{0} - {1}", CrossGeofence.Id, "Not available for monitoring");
                System.Diagnostics.Debug.WriteLine(message);
                CrossGeofence.GeofenceListener.OnError(message);
            }
            return retVal;
        }
public bool AvailableForMonitoring ( ) { bool retVal = false ; RequestAlwaysAuthorization ( ) ; if ( ! CLLocationManager . LocationServicesEnabled ) { string message = string . Format ( " " , CrossGeofence . Id , " " ) ; System . Diagnostics . Debug . WriteLine ( message ) ; CrossGeofence . GeofenceListener . OnError ( message ) ; } else if ( CLLocationManager . Status == CLAuthorizationStatus . Denied || CLLocationManager . Status == CLAuthorizationStatus . Restricted ) { string message = string . Format ( " " , CrossGeofence . Id , " " ) ; System . Diagnostics . Debug . WriteLine ( message ) ; CrossGeofence . GeofenceListener . OnError ( message ) ; } else if ( CLLocationManager . IsMonitoringAvailable ( typeof ( CLRegion ) ) ) { var settings = UIUserNotificationSettings . GetSettingsForTypes ( UIUserNotificationType . Alert | UIUserNotificationType . Badge | UIUserNotificationType . Sound , new NSSet ( ) ) ; UIApplication . SharedApplication . RegisterUserNotificationSettings ( settings ) ; retVal = true ; } else { string message = string . Format ( " " , CrossGeofence . Id , " " ) ; System . Diagnostics . Debug . WriteLine ( message ) ; CrossGeofence . GeofenceListener . OnError ( message ) ; } return retVal ; }
Checks if is available for monitoring
Checks if is available for monitoring
None