public void StopBeacon() { System.Diagnostics.Debug.WriteLine("StopBeacon"); _beaconManager.StopRangingBeacons(_fieldRegion); _beaconManager.StopMonitoring(_fieldRegion); }
void HandleRegionLeft(object sender, CLRegionEventArgs e) { if (e.Region.Identifier.Equals(roximityBeaconId)) { locationManager.StopRangingBeacons(rBeaconRegion); } }
private void StopRanging() { if (secretRegion != null) { manager.StopRangingBeacons(secretRegion); } }
void StopRangingAllRegions() { foreach (CLBeaconRegion region in rangedRegions) { locationManager.StopRangingBeacons(region); } }
public void StopScan() { if (!IsScanning) { return; } foreach (var eventHolder in _beaconEventHolderDict) { iBeacon targetBeacon = eventHolder.Value.ibeacon; var uuid = new NSUuid(targetBeacon.Uuid.ToString()); ushort?major = targetBeacon.Major; ushort?minor = targetBeacon.Minor; CLBeaconRegion beaconRegion; if (major.HasValue && minor.HasValue) { beaconRegion = new CLBeaconRegion(uuid, (ushort)major, (ushort)minor, eventHolder.Value.BeaconIdentifyStr); } else if (major.HasValue) { beaconRegion = new CLBeaconRegion(uuid, (ushort)major, eventHolder.Value.BeaconIdentifyStr); } else { beaconRegion = new CLBeaconRegion(uuid, eventHolder.Value.BeaconIdentifyStr); } _locationManager.StopRangingBeacons(beaconRegion); } IsScanning = false; }
public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); foreach (CLBeaconRegion region in rangedRegions) { locationManager.StopRangingBeacons(region); } }
private void StopAllRanging() { foreach (Lock item in this.Locks) { CLBeaconRegion region = new CLBeaconRegion(new NSUuid(item.LockUUID.ToString()), item.LockName); _locationManager.StopRangingBeacons(region); } }
public void Stop() { foreach (var phoneNumber in _phoneNumerList) { var beaconInfo = GetBeaconInfo(phoneNumber); _locationMgr?.StopMonitoring(beaconInfo.BeaconRegion); _locationMgr?.StopRangingBeacons(beaconInfo.BeaconRegion); } _locationMgr = null; }
protected override void StopMonitoringInternal() { _locationManager.DidRangeBeacons -= LocationManager_DidRangeBeacons; _locationManager.StopUpdatingLocation(); foreach (var region in _beaconRegions) { _locationManager.StopMonitoring(region); _locationManager.StopRangingBeacons(region); } }
public void StopBeacon() { System.Diagnostics.Debug.WriteLine("StopBeacon"); _locationMgr.StopRangingBeacons(clBeaconRegion); _locationMgr.StopMonitoring(clBeaconRegion); _listOfCLBeaconRegion.Clear(); _locationMgr.DidRangeBeacons -= HandleDidRangeBeacons; _locationMgr.StopUpdatingLocation(); }
public void StopScan() { // 停止監聽所有beacon廣播 if (beaconsRegion != null) { foreach (CLBeaconRegion beaconRegion in beaconsRegion) { locationManager.StopRangingBeacons(beaconRegion); } } }
public void Stop() { foreach (var beaconRegion in _listOfCLBeaconRegion) { _locationMgr.StopRangingBeacons(beaconRegion); _locationMgr.StopMonitoring(beaconRegion); } _listOfCLBeaconRegion.Clear(); _locationMgr.DidRangeBeacons -= HandleDidRangeBeacons; _locationMgr.StopUpdatingLocation(); }
public async Task Stop() { _centralManager.StopScan(); foreach (var beaconRegion in _listOfCLBeaconRegion) { _locationMgr.StopRangingBeacons(beaconRegion); _locationMgr.StopMonitoring(beaconRegion); } _listOfCLBeaconRegion.Clear(); _locationMgr.DidRangeBeacons -= HandleDidRangeBeacons; _locationMgr.StopUpdatingLocation(); }
private void StopRanging() { if (!ranging) { return; } if (beaconRegion != null) { manager.StopRangingBeacons(beaconRegion); } if (secretRegion != null) { managerSecret.StopRangingBeacons(secretRegion); } ranging = false; }
public void StopScan() { if (!IsScanning) { return; } foreach (var eventHolder in _beaconEventHolderDict) { var uuid = new NSUuid(eventHolder.Value.ibeacon.Uuid.ToString()); var beaconRegion = new CLBeaconRegion(uuid, eventHolder.Value.ibeacon.Major, eventHolder.Value.ibeacon.Minor, eventHolder.Value.BeaconIdentifyStr); _locationManager.StopRangingBeacons(beaconRegion); } IsScanning = false; }
public void stopranging() { _locationManager.StopRangingBeacons(_region); }
/// <summary> /// Stops the monitoring beacons. /// </summary> public void StopMonitoringBeacons() { if (adapter != null && adapter.IsScanning) { adapter.StopScanningForDevices(); SystemLogger.Log(SystemLogger.Module.PLATFORM, "adapter.StopScanningForDevices()"); } if (regionLocation != null) { locationManager.StopRangingBeacons(regionLocation); } regionLocation = null; List <Beacon> onEnterBeaconsArray = new List <Beacon>(); List <Beacon> onDiscoverBeaconsArray = new List <Beacon>(); List <Beacon> onExitBeaconsArray = new List <Beacon>(); List <string> allBeaconsUIDs = new List <string>(); foreach (Beacon beacon in rangingBeacons.Values) { string beaconUID = uniqueIDForBeacon(beacon); allBeaconsUIDs.Add(beaconUID); if (!rangedBeacons.Keys.Contains(beaconUID)) { onDiscoverBeaconsArray.Add(beacon); SystemLogger.Log(SystemLogger.Module.PLATFORM, "Beacon onDiscoverBeaconsArray:" + onDiscoverBeaconsArray.Count); } else { onEnterBeaconsArray.Add(beacon); SystemLogger.Log(SystemLogger.Module.PLATFORM, "Beacon onEnterBeaconsArray:" + onEnterBeaconsArray.Count); } } foreach (string key in rangedBeacons.Keys) { if (!allBeaconsUIDs.Contains(key)) { Beacon beacon; bool get = rangedBeacons.TryGetValue(key, out beacon); if (get) { onExitBeaconsArray.Add(beacon); } SystemLogger.Log(SystemLogger.Module.PLATFORM, "Beacon onExitBeaconsArray:" + onExitBeaconsArray.Count); } } if (!onEnterBeaconsArray.Any()) { SystemLogger.Log(SystemLogger.Module.PLATFORM, "Beacon OnEntered"); //executeJS("Appverse.Beacon.OnEntered", new Object[]{ onEnterBeaconsArray.ToArray()}); } SystemLogger.Log(SystemLogger.Module.PLATFORM, "Beacon OnDiscover"); //executeJS("Appverse.Beacon.OnDiscover", new Object[]{ onDiscoverBeaconsArray.ToArray()}); if (!onExitBeaconsArray.Any()) { SystemLogger.Log(SystemLogger.Module.PLATFORM, "Beacon OnExited"); //executeJS("Appverse.Beacon.OnExited", new Object[]{ onExitBeaconsArray.ToArray()}); } foreach (String UUID in rangingBeacons.Keys) { if (rangedBeacons.ContainsKey(UUID)) { Beacon beacon; bool get1 = rangingBeacons.TryGetValue(UUID, out beacon); Beacon beaconranged; bool get2 = rangedBeacons.TryGetValue(UUID, out beaconranged); if (!get1 || !get2) { continue; } DistanceType oldProximity = beaconranged.Distance; DistanceType newProximity = beacon.Distance; if (oldProximity != newProximity) { UIApplication.SharedApplication.InvokeOnMainThread(delegate { //executeJS("Appverse.Beacon.OnUpdateProximity",new Object[] { beacon, oldProximity, newProximity }); BeaconUtils.FireUnityJavascriptEvent("Appverse.Beacon.OnUpdateProximity", new Object[] { beacon, oldProximity, newProximity }); }); } } } rangedBeacons.Clear(); rangedBeacons = new Dictionary <string, Beacon>(rangingBeacons); rangingBeacons.Clear(); UIApplication.SharedApplication.InvokeOnMainThread(delegate { BeaconUtils.FireUnityJavascriptEvent("Appverse.Beacon.OnEntered", new Object[] { onEnterBeaconsArray.ToArray() }); BeaconUtils.FireUnityJavascriptEvent("Appverse.Beacon.OnExited", new Object[] { onExitBeaconsArray.ToArray() }); BeaconUtils.FireUnityJavascriptEvent("Appverse.Beacon.OnDiscover", new Object[] { onDiscoverBeaconsArray.ToArray() }); }); }
public void PerformCalibration(EventHandler <CalibrationProgressEventArgs> handler) { if (!isCalibrating) { isCalibrating = true; rangedBeacons.Clear(); percentComplete = 0.0f; ProgressHandler = handler; locationManager.StartRangingBeacons(region); timer = NSTimer.CreateTimer(20.0f, (r) => { locationManager.StopRangingBeacons(region); DispatchQueue.DefaultGlobalQueue.DispatchAsync(new Action(delegate { NSError error = null; List <CLBeacon> allBeacons = new List <CLBeacon> (); int measuredPower = 0; if (!isCalibrating) { error = new CalibrationCancelledError(); } else { foreach (CLBeacon[] beacons in rangedBeacons) { if (beacons.Length > 1) { error = new CalibrationCancelledError(); break; } else { allBeacons.AddRange(beacons); } } if (allBeacons.Count == 0) { error = new CalibrationCancelledError(); } else { allBeacons.Sort(delegate(CLBeacon x, CLBeacon y) { return((x.ValueForKey(Rssi) as NSNumber).CompareTo(y.ValueForKey(Rssi))); }); float power = 0; int number = 0; int outlierPadding = (int)(allBeacons.Count * 0.1f); for (int k = outlierPadding; k < allBeacons.Count - (outlierPadding * 2); k++) { power += ((NSNumber)allBeacons [k].ValueForKey(Rssi)).FloatValue; number++; } measuredPower = (int)power / number; } } DispatchQueue.MainQueue.DispatchAsync(delegate { CalibrationCompletionHandler(this, new CalibrationCompletedEventArgs() { MeasurePower = measuredPower, Error = error }); }); isCalibrating = false; rangedBeacons.Clear(); })); }); NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Default); } }
public void StopFindNearest() { _locationManager.StopRangingBeacons(_allBeaconsRegion); }
public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); _locationManager.StopRangingBeacons(_beaconRegion); }
public void StopRagingBeacons() { System.Diagnostics.Debug.WriteLine("StopBeacon"); _locationManager.StopRangingBeacons(_fieldRegion); }
public override void ViewDidLoad() { base.ViewDidLoad(); locationmanager = new CLLocationManager(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) locationmanager.RequestAlwaysAuthorization(); beaconUUID = new NSUuid(uuid); beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId); beaconRegion.NotifyEntryStateOnDisplay = true; beaconRegion.NotifyOnEntry = true; beaconRegion.NotifyOnExit = true; locationmanager.RegionEntered += (sender, e) => { var notification = new UILocalNotification() { AlertBody = "The Xamarin beacon is close by!" }; UIApplication.SharedApplication.CancelAllLocalNotifications(); UIApplication.SharedApplication.PresentLocalNotificationNow(notification); }; //create beacon region beaconUUID = new NSUuid(uuid); beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId); locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons == null || e.Beacons.Length == 0) return; LabelBeacon.Text = "We found: " + e.Beacons.Length + " beacons"; var beacon = e.Beacons[0]; switch (beacon.Proximity) { case CLProximity.Far: View.BackgroundColor = UIColor.Blue; break; case CLProximity.Near: View.BackgroundColor = UIColor.Yellow; break; case CLProximity.Immediate: View.BackgroundColor = UIColor.Green; break; } LabelDistance.Text = "We are: " + beacon.Accuracy.ToString("##.000"); if (beacon.Accuracy <= .1 && beacon.Proximity == CLProximity.Immediate) { locationmanager.StopRangingBeacons(beaconRegion); var vc = UIStoryboard.FromName("MainStoryboard", null).InstantiateViewController("FoundViewController"); NavigationController.PushViewController(vc, true); } }; locationmanager.StartRangingBeacons(beaconRegion); }
private void DidRegionLeft(object sender, CLRegionEventArgs e) { _locationMgr.StopRangingBeacons(_fieldRegion); }
public override void RegionLeft(CLLocationManager manager, CLRegion region) { //base.RegionLeft(manager, region); Console.WriteLine("Exited Region"); manager.StopRangingBeacons(region as CLBeaconRegion); }
public override void ViewDidLoad() { base.ViewDidLoad(); locationmanager = new CLLocationManager(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locationmanager.RequestAlwaysAuthorization(); } beaconUUID = new NSUuid(uuid); beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId); beaconRegion.NotifyEntryStateOnDisplay = true; beaconRegion.NotifyOnEntry = true; beaconRegion.NotifyOnExit = true; locationmanager.RegionEntered += (sender, e) => { var notification = new UILocalNotification() { AlertBody = "The Xamarin beacon is close by!" }; UIApplication.SharedApplication.CancelAllLocalNotifications(); UIApplication.SharedApplication.PresentLocalNotificationNow(notification); }; //create beacon region beaconUUID = new NSUuid(uuid); beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId); locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons == null || e.Beacons.Length == 0) { return; } LabelBeacon.Text = "We found: " + e.Beacons.Length + " beacons"; var beacon = e.Beacons[0]; switch (beacon.Proximity) { case CLProximity.Far: View.BackgroundColor = UIColor.Blue; break; case CLProximity.Near: View.BackgroundColor = UIColor.Yellow; break; case CLProximity.Immediate: View.BackgroundColor = UIColor.Green; break; } LabelDistance.Text = "We are: " + beacon.Accuracy.ToString("##.000"); if (beacon.Accuracy <= .1 && beacon.Proximity == CLProximity.Immediate) { locationmanager.StopRangingBeacons(beaconRegion); var vc = UIStoryboard.FromName("MainStoryboard", null).InstantiateViewController("FoundViewController"); NavigationController.PushViewController(vc, true); } }; locationmanager.StartRangingBeacons(beaconRegion); }