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


C# CLLocationManager.RequestAlwaysAuthorization方法代码示例

本文整理汇总了C#中CLLocationManager.RequestAlwaysAuthorization方法的典型用法代码示例。如果您正苦于以下问题:C# CLLocationManager.RequestAlwaysAuthorization方法的具体用法?C# CLLocationManager.RequestAlwaysAuthorization怎么用?C# CLLocationManager.RequestAlwaysAuthorization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLLocationManager的用法示例。


在下文中一共展示了CLLocationManager.RequestAlwaysAuthorization方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            locMan = new CLLocationManager();
            locMan.RequestWhenInUseAuthorization();
            locMan.RequestAlwaysAuthorization();
            // Geocode a city to get a CLCircularRegion,
            // and then use our location manager to set up a geofence
            button.TouchUpInside += (o, e) => {

                // clean up monitoring of old region so they don't pile up
                if(region != null)
                {
                    locMan.StopMonitoring(region);
                }

                // Geocode city location to create a CLCircularRegion - what we need for geofencing!
                var taskCoding = geocoder.GeocodeAddressAsync ("Cupertino");
                taskCoding.ContinueWith ((addresses) => {
                    CLPlacemark placemark = addresses.Result [0];
                    region = (CLCircularRegion)placemark.Region;
                    locMan.StartMonitoring(region);

                });
            };

            // This gets called even when the app is in the background - try it!
            locMan.RegionEntered += (sender, e) => {
                Console.WriteLine("You've entered the region");
            };

            locMan.RegionLeft += (sender, e) => {
                Console.WriteLine("You've left the region");
            };
        }
开发者ID:yofanana,项目名称:recipes,代码行数:35,代码来源:GeofencingViewController.cs

示例2: FinishedLaunching

        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            _locationManager = new CLLocationManager();
            _locationManager.AuthorizationChanged += LocationManagerAuthorizationChanged;

            _locationManager.RequestAlwaysAuthorization();

            return true;
        }
开发者ID:jimbobbennett,项目名称:BuildingiBeaconAppsUsingXamarin,代码行数:12,代码来源:AppDelegate.cs

示例3: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            _locationManager = new CLLocationManager();
            _locationManager.AuthorizationChanged += LocationManagerAuthorizationChanged;
            _locationManager.DidRangeBeacons += LocationManagerDidRangeBeacons;

            _locationManager.RequestAlwaysAuthorization();

            _region = new CLBeaconRegion(new NSUuid("18E1FDEA-15E6-425E-B88C-2642B8F3C378"), "MyRegion");
        }
开发者ID:jimbobbennett,项目名称:BuildingiBeaconAppsUsingXamarin,代码行数:13,代码来源:ViewController.cs

示例4: LocationManager

		public LocationManager ()
		{
			this.locMgr = new CLLocationManager();
			// iOS 8 has additional permissions requirements
			//
			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				locMgr.RequestAlwaysAuthorization (); // works in background
				//locMgr.RequestWhenInUseAuthorization (); // only in foreground
			}

			LocationUpdated += PrintLocation;

		}
开发者ID:g7steve,项目名称:monotouch-samples,代码行数:13,代码来源:LocationManager.cs

示例5: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            _locationManager = new CLLocationManager();
            _locationManager.Delegate = new MyLocationDelegate();

            // Enable location mode, request if not authorized
            if (CLLocationManager.Status == CLAuthorizationStatus.AuthorizedAlways) {
                _locationManager.StartMonitoringSignificantLocationChanges ();
            } else {
                _locationManager.RequestAlwaysAuthorization ();
            }
        }
开发者ID:bytedreamer,项目名称:BusyBot-iOS,代码行数:14,代码来源:MainTabBarController.cs

示例6: PlatformSpecificStart

        protected override void PlatformSpecificStart(MvxLocationOptions options)
        {
            lock (this)
            {
                if (_locationManager != null)
                    throw new MvxException("You cannot start the MvxLocation service more than once");

                _locationManager = new CLLocationManager();
                _locationManager.Delegate = new LocationDelegate(this);

                if (options.MovementThresholdInM > 0)
                {
                    _locationManager.DistanceFilter = options.MovementThresholdInM;
                }
                else
                {
                    _locationManager.DistanceFilter = CLLocationDistance.FilterNone;
                }
                _locationManager.DesiredAccuracy = options.Accuracy == MvxLocationAccuracy.Fine ? CLLocation.AccuracyBest : CLLocation.AccuracyKilometer;
                if (options.TimeBetweenUpdates > TimeSpan.Zero)
                {
                    Mvx.Warning("TimeBetweenUpdates specified for MvxLocationOptions - but this is not supported in iOS");
                }


				if (options.TrackingMode == MvxLocationTrackingMode.Background)
				{
					if (IsIOS8orHigher)
					{
						_locationManager.RequestAlwaysAuthorization ();
					}
					else
					{
						Mvx.Warning ("MvxLocationTrackingMode.Background is not supported for iOS before 8");
					}
				}
				else
				{
					if (IsIOS8orHigher)
					{
						_locationManager.RequestWhenInUseAuthorization ();
					}
				}

                if (CLLocationManager.HeadingAvailable)
                    _locationManager.StartUpdatingHeading();

                _locationManager.StartUpdatingLocation();
            }
        }
开发者ID:Everbridge,项目名称:sm-MvvmCross,代码行数:50,代码来源:MvxTouchLocationWatcher.cs

示例7: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.

			var LocationManager = new CLLocationManager();
			LocationManager.RequestWhenInUseAuthorization ();
			LocationManager.RequestAlwaysAuthorization ();

			CLCircularRegion region = new CLCircularRegion (new CLLocationCoordinate2D (+46.833120, +15.34901), 1000.0, "FF Gussendorf");

			if (CLLocationManager.LocationServicesEnabled) {

				LocationManager.DidStartMonitoringForRegion += (o, e) => {
					Console.WriteLine ("Now monitoring region {0}", e.Region.ToString ());
				};

				LocationManager.RegionEntered += (o, e) => {
					Console.WriteLine ("Just entered " + e.Region.ToString ());
				};

				LocationManager.RegionLeft += (o, e) => {
					Console.WriteLine ("Just left " + e.Region.ToString ());
				};

				LocationManager.Failed += (o, e) => {
					Console.WriteLine (e.Error);
				};

				LocationManager.UpdatedLocation += (o, e) => {
					Console.WriteLine ("Lat " + e.NewLocation.Coordinate.Latitude + ", Long " + e.NewLocation.Coordinate.Longitude);
				};

				LocationManager.LocationsUpdated += (o, e) => Console.WriteLine ("Location change received");

				LocationManager.StartMonitoring (region);
				LocationManager.StartMonitoringSignificantLocationChanges ();

				//LocationManager.StopMonitoringSignificantLocationChanges ();



			} else {
				Console.WriteLine ("This app requires region monitoring, which is unavailable on this device");
			}
		}
开发者ID:martinlipp,项目名称:GeoFence,代码行数:46,代码来源:ViewController.cs

示例8: FinishedLaunching

        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            AppDelegate.Self = this;
            global::Xamarin.Forms.Forms.Init();
            App.ScreenSize = new Size(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);
            LoadApplication(new App());

            LocationManager = new CLLocationManager();
            var iOSVersion = UIDevice.CurrentDevice.SystemVersion.Split('.');
            if (Convert.ToInt32(iOSVersion[0]) >= 8)
            {
                LocationManager.RequestAlwaysAuthorization();
                LocationManager.RequestWhenInUseAuthorization();
            }

            return base.FinishedLaunching(app, options);
        }
开发者ID:nodoid,项目名称:estimote-xf,代码行数:17,代码来源:AppDelegate.cs

示例9: LocationManager

		public LocationManager ()
		{
			this.locMgr = new CLLocationManager ();

			this.locMgr.PausesLocationUpdatesAutomatically = false; 

			// iOS 8 has additional permissions requirements
			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				locMgr.RequestAlwaysAuthorization (); // works in background
				//locMgr.RequestWhenInUseAuthorization (); // only in foreground
			}

			if (UIDevice.CurrentDevice.CheckSystemVersion (9, 0)) {
				locMgr.AllowsBackgroundLocationUpdates = true;
			}
			LocationUpdated += PrintLocation;
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:17,代码来源:LocationManager.cs

示例10: FinishedLaunching

        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            var userNotificationSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert, new NSSet());
            UIApplication.SharedApplication.RegisterUserNotificationSettings(userNotificationSettings);

            _beaconRegion = new CLBeaconRegion(new NSUuid("17BFFC6C-A5DF-4198-ADAE-73D616A50009"), "My Region");
            _beaconRegion.NotifyOnEntry = true;
            _beaconRegion.NotifyOnExit = true;

            _beaconManager = new CLLocationManager();

            _beaconManager.AuthorizationChanged += BeaconManagerAuthorizationStatusChanged;
            _beaconManager.RegionEntered += BeaconManagerEnteredRegion;
            _beaconManager.RegionLeft += BeaconManagerExitedRegion;
            _beaconManager.RequestAlwaysAuthorization();

            return true;
        }
开发者ID:jimbobbennett,项目名称:iBeaconDemo,代码行数:18,代码来源:AppDelegate.cs

示例11: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Near = UIImage.FromBundle ("Images/square_near");
            Far = UIImage.FromBundle ("Images/square_far");
            Immediate = UIImage.FromBundle ("Images/square_immediate");
            Unknown = UIImage.FromBundle ("Images/square_unknown");

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

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

            locationmanager = new CLLocationManager ();
            locationmanager.RequestAlwaysAuthorization ();

            locationmanager.RegionEntered += (object sender, CLRegionEventArgs e) => {

                    var notification = new UILocalNotification () { AlertBody = "The Xamarin beacon is close by!" };
                    UIApplication.SharedApplication.CancelAllLocalNotifications();
                    UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
            };

            locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {

                if (e.Beacons.Length > 0) {

                    CLBeacon beacon = e.Beacons [0];
                    //this.Title = beacon.Proximity.ToString() + " " +beacon.Major + "." + beacon.Minor;
                }

                dataSource.Beacons = e.Beacons;
                TableView.ReloadData();
            };

            locationmanager.StartMonitoring (beaconRegion);
            locationmanager.StartRangingBeacons (beaconRegion);

            TableView.Source = dataSource = new DataSource (this);
        }
开发者ID:dinhminhquoi,项目名称:iBeaconsEverywhere,代码行数:43,代码来源:MasterViewController.cs

示例12: FinishedLaunching

        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            var userNotificationSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert, new NSSet());
            UIApplication.SharedApplication.RegisterUserNotificationSettings(userNotificationSettings);

            _locationManager = new CLLocationManager();
            _locationManager.AuthorizationChanged += LocationManagerAuthorizationChanged;
            _locationManager.RegionEntered += LocationManagerRegionEntered;
            _locationManager.RegionLeft += LocationManagerRegionLeft;

            _locationManager.RequestAlwaysAuthorization();

            _region = new CLBeaconRegion(new NSUuid("18E1FDEA-15E6-425E-B88C-2642B8F3C378"), "MyRegion");

            return true;
        }
开发者ID:jimbobbennett,项目名称:BuildingiBeaconAppsUsingXamarin,代码行数:19,代码来源:AppDelegate.cs

示例13: LocationManager

		public LocationManager ()
		{
			this.locMgr = new CLLocationManager();
			// iOS 8 has additional permissions requirements
			//
			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				locMgr.RequestAlwaysAuthorization (); // works in background
				//locMgr.RequestWhenInUseAuthorization (); // only in foreground
			}

			// iOS 9 requires the following for background location updates
			// By default this is set to false and will not allow background updates
			if (UIDevice.CurrentDevice.CheckSystemVersion (9, 0)) {
				locMgr.AllowsBackgroundLocationUpdates = true;
			}

			LocationUpdated += PrintLocation;

		}
开发者ID:BytesGuy,项目名称:monotouch-samples,代码行数:19,代码来源:LocationManager.cs

示例14: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			map.GetViewForAnnotation = (mapView, annotation) => {
				return new MKPinAnnotationView (annotation, string.Empty) {
					Draggable = true
				};
			};

			locationManager = new CLLocationManager {
				DistanceFilter = CLLocationDistance.FilterNone,
				DesiredAccuracy = CLLocation.AccuracyBest,
			};

			locationManager.LocationsUpdated += OnLocationsUpdated;

			locationManager.RequestAlwaysAuthorization ();
			locationManager.StartUpdatingLocation ();
		}
开发者ID:RangoJT,项目名称:monotouch-samples,代码行数:20,代码来源:CKRecordViewController.cs

示例15: MasterViewController

        public MasterViewController()
            : base("MasterViewController", null)
        {
            //Title = NSBundle.MainBundle.LocalizedString("Master", "iBeacons Everywhere");

            Near = UIImage.FromBundle("Images/square_near");
            Far = UIImage.FromBundle("Images/square_far");
            Immediate = UIImage.FromBundle("Images/square_immediate");
            Unknown = UIImage.FromBundle("Images/square_unknown");

            _locationManager = new CLLocationManager();
            _locationManager.RequestAlwaysAuthorization();

            _locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) =>
            {
                _dataSource.Beacons = e.Beacons;
                TableView.ReloadData();
            };

            _beaconRegions = new List<CLBeaconRegion>();
        }
开发者ID:stronachconsult,项目名称:iBeaconsEverywhere,代码行数:21,代码来源:MasterViewController.cs


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