public BeaconLocateriOS()
 {
     SetupBeaconRanging();
     locationManager.StartMonitoring(rBeaconRegion);
     locationManager.RequestState(rBeaconRegion);
     locationManager.StartMonitoring(eBeaconRegion);
     locationManager.RequestState(eBeaconRegion);
 }
 public BeaconLocateriOS()
 {
     //iBeacon-Einstellungen laden und die Suche nach iBeacon beginnen
     SetupBeaconRanging();
     locationManager.StartMonitoring(rBeaconRegion);
     locationManager.RequestState(rBeaconRegion);
 }
示例#3
0
        public async Task <GeofenceStatus> RequestState(GeofenceRegion region, CancellationToken?cancelToken)
        {
            var tcs = new TaskCompletionSource <GeofenceStatus>();

            cancelToken?.Register(() => tcs.TrySetCanceled());

            var handler = new EventHandler <CLRegionStateDeterminedEventArgs>((sender, args) =>
            {
                var clregion = args.Region as CLCircularRegion;
                if (clregion?.Identifier.Equals(region.Identifier) ?? false)
                {
                    var state = FromNative(args.State);
                    tcs.TrySetResult(state);
                }
            });

            try
            {
                locationManager.DidDetermineState += handler;
                var native = ToNative(region);
                locationManager.RequestState(native);
                return(await tcs.Task);
            }
            finally
            {
                locationManager.DidDetermineState -= handler;
            }
        }
 /// <summary>
 /// Handles Ranging on/off
 /// </summary>
 /// <param name="shouldRange">If set to <c>true</c> should range.</param>
 void RangeBeacons()
 {
     if (!(UIApplication.SharedApplication.ApplicationState == UIApplicationState.Background))
     {
         imgAdd.Image    = UIImage.FromBundle(Globals.DefaultImage);
         lblAddtext.Text = Globals.DefaultText;
     }
     _locationManager.StartRangingBeacons(_beaconRegion);
     _locationManager.RequestState(_beaconRegion);
 }
示例#5
0
        public BeaconLocateriOS()
        {
            SetupBeaconRanging();
            locationManager.StartMonitoring(rBeaconRegion);
            locationManager.RequestState(rBeaconRegion);

            if (locationManager == null)
            {
                locationManager = new CLLocationManager();
                locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
                locationManager.HeadingFilter   = 1;
                locationManager.UpdatedHeading += LocationManager_UpdatedHeading;;
            }
            else
            {
                locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
                locationManager.HeadingFilter   = 1;
                locationManager.UpdatedHeading += LocationManager_UpdatedHeading;;
            }
            locationManager.StartUpdatingHeading();
        }
        void AddRegion(GeofenceCircularRegion region)
        {
            CLRegion cRegion = null;


            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                cRegion = new CLCircularRegion(new CLLocationCoordinate2D(region.Latitude, region.Longitude), (region.Radius > locationManager.MaximumRegionMonitoringDistance) ? locationManager.MaximumRegionMonitoringDistance : region.Radius, region.Id);
            }
            else
            {
                cRegion = new CLRegion(new CLLocationCoordinate2D(region.Latitude, region.Longitude), (region.Radius > locationManager.MaximumRegionMonitoringDistance) ? locationManager.MaximumRegionMonitoringDistance : region.Radius, region.Id);
            }


            cRegion.NotifyOnEntry = region.NotifyOnEntry || region.NotifyOnStay;
            cRegion.NotifyOnExit  = region.NotifyOnExit;



            locationManager.StartMonitoring(cRegion);
            locationManager.RequestState(cRegion);
        }
示例#7
0
        public void RefreshRegionsAndLandmarks( )
        {
            // first, are services enabled and is the device capable?
            if (AuthorizationStatus == CLAuthorizationStatus.AuthorizedAlways)
            {
                Console.WriteLine("LocationManager: RefreshRegionsAndLandmarks");

                // This will reset our landmark, and get an update
                // from each region with our current state in it (in or out).
                // This allows us to "sync" the app's status with where the location service
                // thinks we are.
                CurrentLandMark = null;

                foreach (TrackedRegion region in Regions)
                {
                    CLLocationManager.RequestState(region.Region);
                }
            }
            else
            {
                Console.WriteLine("LocationManager: RefreshRegionsAndLandmarks NOT AUTHORIZED. PERMISSIONS: {0}", AuthorizationStatus);
            }
        }
        /// <summary>
        /// Geofence plugin iOS implementation
        /// </summary>
        public GeofenceImplementation()
        {
            mGeofenceResults = new Dictionary <string, GeofenceResult>();

            using (var pool = new NSAutoreleasePool())
            {
                pool.InvokeOnMainThread(() => {
                    locationManager = new CLLocationManager();
                    locationManager.DidStartMonitoringForRegion += DidStartMonitoringForRegion;
                    locationManager.RegionEntered     += RegionEntered;
                    locationManager.RegionLeft        += RegionLeft;
                    locationManager.Failed            += OnFailure;
                    locationManager.DidDetermineState += DidDetermineState;
                    locationManager.LocationsUpdated  += LocationsUpdated;
                });
            }
            string priorityType = "Balanced Power";

            switch (CrossGeofence.GeofencePriority)
            {
            case GeofencePriority.HighAccuracy:
                priorityType = "High Accuracy";
                locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
                break;

            case GeofencePriority.AcceptableAccuracy:
                priorityType = "Acceptable Accuracy";
                locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
                break;

            case GeofencePriority.MediumAccuracy:
                priorityType = "Medium Accuracy";
                locationManager.DesiredAccuracy = CLLocation.AccuracyHundredMeters;
                break;

            case GeofencePriority.LowAccuracy:
                priorityType = "Low Accuracy";
                locationManager.DesiredAccuracy = CLLocation.AccuracyKilometer;
                break;

            case GeofencePriority.LowestAccuracy:
                priorityType = "Lowest Accuracy";
                locationManager.DesiredAccuracy = CLLocation.AccuracyThreeKilometers;
                break;

            default:
                locationManager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation;
                break;
            }
            System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Location priority set to", priorityType));

            if (CrossGeofence.SmallestDisplacement > 0)
            {
                locationManager.DistanceFilter = CrossGeofence.SmallestDisplacement;
                System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2} meters", CrossGeofence.Id, "Location smallest displacement set to", CrossGeofence.SmallestDisplacement));
            }



            if (locationManager.MonitoredRegions.Count > 0 && IsMonitoring)
            {
                NSSet monitoredRegions = locationManager.MonitoredRegions;


                foreach (CLCircularRegion region in monitoredRegions)
                {
                    //If not on regions remove on startup since that region was set not persistent
                    if (!Regions.ContainsKey(region.Identifier))
                    {
                        locationManager.StopMonitoring(region);
                    }
                    else
                    {
                        locationManager.RequestState(region);
                    }
                }

                locationManager.StartMonitoringSignificantLocationChanges();

                string message = string.Format("{0} - {1} {2} region(s)", CrossGeofence.Id, "Actually monitoring", locationManager.MonitoredRegions.Count);
                System.Diagnostics.Debug.WriteLine(message);
            }

            SetLastKnownLocation(locationManager.Location);
        }
示例#9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var beaconUUID   = new NSUuid(uuid);
            var beaconRegion = new CLBeaconRegion(beaconUUID, beaconId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry             = true;
            beaconRegion.NotifyOnExit = true;

            locationManager = new CLLocationManager();
            locationManager.RequestWhenInUseAuthorization();

            locationManager.DidStartMonitoringForRegion += (object sender, CLRegionEventArgs e) => {
                locationManager.RequestState(e.Region);
            };

            locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => {
                if (e.Region.Identifier == beaconId)
                {
                    Console.WriteLine("beacon region entered");
                }
            };

            locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => {
                switch (e.State)
                {
                case CLRegionState.Inside:
                    Console.WriteLine("region state inside");
                    break;

                case CLRegionState.Outside:
                    Console.WriteLine("region state outside");
                    break;

                case CLRegionState.Unknown:
                default:
                    Console.WriteLine("region state unknown");
                    break;
                }
            };

            locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
                if (e.Beacons.Length > 0)
                {
                    int major, minor;

                    foreach (var beacon in e.Beacons)
                    {
                        major = (int)beacon.Major;
                        minor = (int)beacon.Minor;

//                        Console.WriteLine("Found Beacon with Major = {0} Minor = {1}", major, minor);

                        // Lock on to a specific iBeacon since there are many of them in the Darwin lounge
                        if (major == 51093 && minor == 43988)
                        {
                            switch (beacon.Proximity)
                            {
                            case CLProximity.Immediate:
                                message = "Immediate";
                                break;

                            case CLProximity.Near:
                                message = "Near";
                                break;

                            case CLProximity.Far:
                                message = "Far";
                                break;

                            case CLProximity.Unknown:
                                message = "Unknown";
                                break;
                            }

                            if (previousProximity != beacon.Proximity)
                            {
                                Console.WriteLine(message);
                            }

                            previousProximity = beacon.Proximity;
                        }
                    }
                }
            };

            locationManager.StartMonitoring(beaconRegion);
            locationManager.StartRangingBeacons(beaconRegion);
        }
      /// <summary>
      /// Geofence plugin iOS implementation
      /// </summary>
      public GeofenceImplementation()
      {

          mGeofenceResults = new Dictionary<string, GeofenceResult>();

          locationManager = new CLLocationManager();
          locationManager.DidStartMonitoringForRegion += DidStartMonitoringForRegion;
          locationManager.RegionEntered += RegionEntered;
          locationManager.RegionLeft +=RegionLeft;
          locationManager.Failed += OnFailure;
          locationManager.DidDetermineState += DidDetermineState;
          locationManager.LocationsUpdated += LocationsUpdated;
          string priorityType = "Balanced Power";
          switch(CrossGeofence.GeofencePriority)
          {
              case GeofencePriority.HighAccuracy:
                  priorityType = "High Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
                  break;
              case GeofencePriority.AcceptableAccuracy:
                  priorityType = "Acceptable Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
                  break;
              case GeofencePriority.MediumAccuracy:
                  priorityType = "Medium Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyHundredMeters;
                  break;
              case GeofencePriority.LowAccuracy:
                  priorityType = "Low Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyKilometer;
                  break;
              case GeofencePriority.LowestAccuracy:
                  priorityType = "Lowest Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyThreeKilometers;
                  break;
              default:
                  locationManager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation;
                  break;
          }
          System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Location priority set to", priorityType));
    
          if(CrossGeofence.SmallestDisplacement>0)
          {
              locationManager.DistanceFilter = CrossGeofence.SmallestDisplacement;
              System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2} meters", CrossGeofence.Id, "Location smallest displacement set to", CrossGeofence.SmallestDisplacement));
          }

         

          if (locationManager.MonitoredRegions.Count > 0 && IsMonitoring)
          {

              NSSet monitoredRegions = locationManager.MonitoredRegions;
             

              foreach (CLCircularRegion region in monitoredRegions)
              {
                  //If not on regions remove on startup since that region was set not persistent
                  if (!Regions.ContainsKey(region.Identifier))
                  {
                      locationManager.StopMonitoring(region);
                  }
                  else
                  {
                      locationManager.RequestState(region);
                  }
                 
              }

              locationManager.StartMonitoringSignificantLocationChanges();

              string message = string.Format("{0} - {1} {2} region(s)", CrossGeofence.Id, "Actually monitoring", locationManager.MonitoredRegions.Count);
              System.Diagnostics.Debug.WriteLine(message);
              
          }

          SetLastKnownLocation(locationManager.Location);
          
      }
示例#11
0
 /// <summary>
 /// 位置情報の観測が開始された際に、利用の認証を要求します。
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="region"></param>
 public override void DidStartMonitoringForRegion(CLLocationManager manager, CLRegion region)
 {
     Console.WriteLine("Start monitoring for {0}", region.Identifier);
     manager.RequestState(region);
 }
示例#12
0
        public bool startLookingForBeacons()
        {
            BeaconList.init ();
            Console.WriteLine ("create called");
            var beaconUUID = new NSUuid (uuid);
            var beaconRegion = new CLBeaconRegion (beaconUUID, beaconId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry = true;
            beaconRegion.NotifyOnExit = true;

            locationManager = new CLLocationManager ();

            locationManager.RequestWhenInUseAuthorization ();

            locationManager.DidStartMonitoringForRegion += (object sender, CLRegionEventArgs e) => {
                locationManager.RequestState (e.Region);
            };

            locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => {
                if (e.Region.Identifier == beaconId) {
                    Console.WriteLine ("beacon region entered");
                }
            };

            locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => {

                switch (e.State) {
                case CLRegionState.Inside:
                    Console.WriteLine ("region state inside");
                    break;
                case CLRegionState.Outside:
                    Console.WriteLine ("region state outside");
                    break;
                case CLRegionState.Unknown:
                default:
                    Console.WriteLine ("region state unknown");
                    break;
                }
            };

            locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
                if (e.Beacons.Length > 0) {
                    List<BeaconModel> beacons = new List<BeaconModel> {};
                    for (int i = 0; i < e.Beacons.Length; i++)
                    {
                        CLBeacon beacon = e.Beacons [i];
                        string proximity = "";
                        var major = (int) beacon.Major;
                        var minor = (int) beacon.Minor;
                        var accuracy = beacon.Accuracy;
                        Console.WriteLine(beacon.Major.ToString() + " " + beacon.Minor.ToString() + " " + beacon.Accuracy.ToString() );

                        switch (beacon.Proximity) {
                        case CLProximity.Immediate:
                            proximity = "Immediate";
                            break;
                        case CLProximity.Near:
                            proximity = "Near";
                            break;
                        case CLProximity.Far:
                            proximity = "Far";
                            break;
                        case CLProximity.Unknown:
                            proximity = "Unknown";
                            break;
                        }
                        BeaconModel beaconModel = new BeaconModel()
                        {
                            Major = major,
                            Minor = minor,
                            Proximity = proximity,
                            Region = e.Region.ToString(),
                            Accuracy = accuracy
                        };

            //						EventHandler<BeaconTest.onResultEventArgs> handler = onResultEvent;
            //						if (handler != null)
            //						{
            //							handler(this, new BeaconTest.onResultEventArgs{result = message});
            //						}
                        beacons.Add(beaconModel);
                    }
                    BeaconList.nearbyBeacons = BeaconList.updateList(beacons, BeaconList.nearbyBeacons, _numberOfFailedIterationsToRemove: 10);
                    BeaconList.lastUpdated = (Int32)(DateTime.UtcNow.Subtract(new  DateTime(1970,1,1,0,0,0))).TotalSeconds;
                    BeaconList.beaconsUpdated.Invoke();
                }
            };

            locationManager.StartMonitoring (beaconRegion);
            locationManager.StartRangingBeacons (beaconRegion);
            return true;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            CLCircularRegion region = new CLCircularRegion(new CLLocationCoordinate2D(10.009176843388, 76.3615990792536), 20.0, "Jubin's Desk");

            locLabel = (UILabel)this.View.ViewWithTag(2004);
            locLabel1 = (UILabel)this.View.ViewWithTag(2005);
            statusLabel = (UILabel)this.View.ViewWithTag(2006);
            locLabel.Text = "Location...";
            locManager = new CLLocationManager();
            locManager.RequestAlwaysAuthorization ();
            //locManager.RequestWhenInUseAuthorization ();
            locManager.DesiredAccuracy = CLLocation.AccuracyBest;
            //locManager.DistanceFilter = 5.0;
            locManager.UpdatedLocation+=(object sender, CLLocationUpdatedEventArgs e) => {
                locLabel.Text = "Longitude: "+e.NewLocation.Coordinate.Longitude+" Lattitude: "+e.NewLocation.Coordinate.Latitude;
                System.Diagnostics.Debug.WriteLine("Longitude: "+e.NewLocation.Coordinate.Longitude+" Lattitude: "+e.NewLocation.Coordinate.Latitude);
            };
            /* this gets fired and works fine */
            locManager.LocationsUpdated+=(object sender, CLLocationsUpdatedEventArgs e) => {
                foreach (CLLocation aLocation in e.Locations)
                {
                    locLabel1.Text = "Longitude: "+aLocation.Coordinate.Longitude.ToString()+" Lattitude: "+aLocation.Coordinate.Latitude.ToString();
                    if (region.ContainsCoordinate(new CLLocationCoordinate2D(aLocation.Coordinate.Latitude, aLocation.Coordinate.Longitude)))
                    {
                        statusLabel.Text = "Normal location update: cordinates inside the region";
                    }
                    else
                    {
                        statusLabel.Text = "Normal location update: cordinates outside the region";
                    }
                }
            };
            locManager.StartUpdatingLocation();

            if (CLLocationManager.IsMonitoringAvailable (typeof(CLCircularRegion)))
            {
                /* This doesn't get fired */
                locManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => {
                    switch(e.State)
                    {
                        case CLRegionState.Inside:
                        InvokeOnMainThread(()=>{
                            locLabel.Text = "Iniside...";
                            UIAlertView testAlert = new UIAlertView ();
                            testAlert.AddButton ("OK");
                            testAlert.Title = "Entered";
                            testAlert.Message = "Region "+e.Region.ToString();
                            testAlert.Show();
                        });
                        break;

                        case CLRegionState.Outside:
                        InvokeOnMainThread(()=>{
                            locLabel.Text = "Outside...";
                            UIAlertView testAlert1 = new UIAlertView ();
                            testAlert1.AddButton ("OK");
                            testAlert1.Title = "Exit";
                            testAlert1.Message = "Region "+e.Region.ToString();
                            testAlert1.Show();
                        });
                        break;

                        case CLRegionState.Unknown:
                        InvokeOnMainThread(()=>{
                            locLabel.Text = "Unknown state for region...";
                        });
                        break;
                        default:
                        break;
                    }
                };
                /* This works and gets fired */
                locManager.DidStartMonitoringForRegion += (o, e) => {
                    InvokeOnMainThread(()=>{
                        locManager.RequestState(e.Region);
                        locLabel.Text = "Now monitoring region : "+ e.Region.ToString ();
                    });
                };
                /* This doesn't get fired */
                locManager.DidVisit+=(object sender, CLVisitedEventArgs e) => {
                    InvokeOnMainThread(()=>{
                        locLabel.Text = "Did visit region...";
                        UIAlertView testAlert = new UIAlertView ();
                        testAlert.AddButton ("OK");
                        testAlert.Title = "Visited";
                        testAlert.Message = "Region "+e.Visit.Coordinate.Latitude.ToString()+" | "+e.Visit.Coordinate.Longitude.ToString();
                        testAlert.Show();
                    });
                };
                /* This doesn't get fired */
                locManager.RegionEntered += (o, e) => {
                    InvokeOnMainThread(()=>{
                        UIAlertView testAlert = new UIAlertView ();
                        testAlert.AddButton ("OK");
                        testAlert.Title = "Entered";
                        testAlert.Message = "Region "+e.Region.ToString();
                        testAlert.Show();
                        locLabel.Text = "Entered: "+e.Region.ToString();
                    });
                };
                /* This doesn't get fired */
                locManager.RegionLeft += (o, e) => {
                    InvokeOnMainThread(()=>{
                        UIAlertView testAlert = new UIAlertView ();
                        testAlert.AddButton ("OK");
                        testAlert.Title = "Exit";
                        testAlert.Message = "Region "+e.Region.ToString();
                        testAlert.Show();
                        locLabel.Text = "Left: "+e.Region.ToString();
                    });
                };
                locManager.StartMonitoring (region);
            }
            else
            {
            }
            // Perform any additional setup after loading the view, typically from a nib.
        }
示例#14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var beaconUUID   = new NSUuid(uuid);
            var beaconRegion = new CLBeaconRegion(beaconUUID, beaconId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry             = true;
            beaconRegion.NotifyOnExit = true;

            locationManager = new CLLocationManager();

            locationManager.RequestWhenInUseAuthorization();

            locationManager.DidStartMonitoringForRegion += (object sender, CLRegionEventArgs e) => {
                locationManager.RequestState(e.Region);
            };

            locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => {
                if (e.Region.Identifier == beaconId)
                {
                    Console.WriteLine("beacon region entered");
                }
            };

            locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => {
                switch (e.State)
                {
                case CLRegionState.Inside:
                    Console.WriteLine("region state inside");
                    break;

                case CLRegionState.Outside:
                    Console.WriteLine("region state outside");
                    break;

                case CLRegionState.Unknown:
                default:
                    Console.WriteLine("region state unknown");
                    break;
                }
            };

            locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
                if (e.Beacons.Length > 0)
                {
                    CLBeacon beacon = e.Beacons [0];

                    switch (beacon.Proximity)
                    {
                    case CLProximity.Immediate:
                        message = "Immediate";
                        break;

                    case CLProximity.Near:
                        message = "Near";
                        break;

                    case CLProximity.Far:
                        message = "Far";
                        break;

                    case CLProximity.Unknown:
                        message = "Unknown";
                        break;
                    }

                    if (previousProximity != beacon.Proximity)
                    {
                        Console.WriteLine(message);
                    }
                    previousProximity = beacon.Proximity;
                }
            };

            locationManager.StartMonitoring(beaconRegion);
            locationManager.StartRangingBeacons(beaconRegion);
        }
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            var beaconUUID = new NSUuid (uuid);
            var beaconRegion = new CLBeaconRegion (beaconUUID, beaconId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry = true;
            beaconRegion.NotifyOnExit = true;

            locationManager = new CLLocationManager ();

            locationManager.RequestWhenInUseAuthorization ();

            locationManager.DidStartMonitoringForRegion += (object sender, CLRegionEventArgs e) => {
                locationManager.RequestState (e.Region);
            };

            locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => {
                if (e.Region.Identifier == beaconId) {
                    Console.WriteLine ("beacon region entered");
                }
            };

            locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => {

                switch (e.State) {
                case CLRegionState.Inside:
                    Console.WriteLine ("region state inside");
                    break;
                case CLRegionState.Outside:
                    Console.WriteLine ("region state outside");
                    break;
                case CLRegionState.Unknown:
                default:
                    Console.WriteLine ("region state unknown");
                    break;
                }
            };

            locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
                if (e.Beacons.Length > 0) {

                    CLBeacon beacon = e.Beacons [0];

                    switch (beacon.Proximity) {
                    case CLProximity.Immediate:
                        message = "Immediate";
                        break;
                    case CLProximity.Near:
                        message = "Near";
                        break;
                    case CLProximity.Far:
                        message = "Far";
                        break;
                    case CLProximity.Unknown:
                        message = "Unknown";
                        break;
                    }

                    if (previousProximity != beacon.Proximity) {
                        Console.WriteLine (message);
                    }
                    previousProximity = beacon.Proximity;
                }
            };

            locationManager.StartMonitoring (beaconRegion);
            locationManager.StartRangingBeacons (beaconRegion);
        }
示例#16
0
 void LocationManager_DidStartMonitoringForRegion(object sender, CLRegionEventArgs e)
 {
     _manager.RequestState(e.Region);
 }