本文整理汇总了C#中CLLocationManager.StopRangingBeacons方法的典型用法代码示例。如果您正苦于以下问题:C# CLLocationManager.StopRangingBeacons方法的具体用法?C# CLLocationManager.StopRangingBeacons怎么用?C# CLLocationManager.StopRangingBeacons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLLocationManager
的用法示例。
在下文中一共展示了CLLocationManager.StopRangingBeacons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
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);
}