当前位置: 首页>>代码示例>>C#>>正文


C# CLLocationManager.StopRangingBeacons方法代码示例

本文整理汇总了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);
        }
开发者ID:HanhTruong,项目名称:iBeaconsEverywhere,代码行数:65,代码来源:iBeaconsSimple.iOSViewController.cs


注:本文中的CLLocationManager.StopRangingBeacons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。