/// <summary> /// 位置情報利用の認証状態が変わった際に、位置情報のモニタリングを開始します。 /// </summary> /// <param name="manager"></param> /// <param name="status"></param> public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { var adapter = new DbAdapter_iOS(); adapter.AddDeviceLog($"位置情報の認証状態が更新", status.ToString()); // TODO ステータス名表示に if (status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse) { //iBeacon領域判定の有効化 if (CLLocationManager.IsMonitoringAvailable(typeof(CLBeaconRegion))) { 研究室領域.NotifyEntryStateOnDisplay = false; 研究室領域.NotifyOnEntry = true; 研究室領域.NotifyOnExit = true; manager.StartMonitoring(研究室領域); } //ジオフェンス領域の有効化 if (CLLocationManager.IsMonitoringAvailable(typeof(CLCircularRegion))) { foreach (var gr in 学内領域) { gr.NotifyOnEntry = true; gr.NotifyOnExit = true; manager.StartMonitoring(gr); } } } else { //位置情報利用の許可を貰う manager.RequestAlwaysAuthorization(); } }
public override void ViewDidLoad() { base.ViewDidLoad(); _mapView = new MKMapView { TranslatesAutoresizingMaskIntoConstraints = false }; _mapView.Delegate = new MyMKMapViewDelegate(); _locationManager = new CLLocationManager(); _locationManager.Delegate = new MyCLLocationManagerDelegate(_locationManager, _mapView); CLAuthorizationStatus status = CLLocationManager.Status; if (status == CLAuthorizationStatus.NotDetermined) { Console.WriteLine("didChangeAuthorizationStatus"); _locationManager.RequestWhenInUseAuthorization(); } var willEnterObj = UIApplication.Notifications.ObserveWillEnterForeground((sender, e) => InitUsersLocation()); _locationManager.DesiredAccuracy = CLLocation.AccuracyBest; _locationManager.DistanceFilter = 300; View.AddSubview(_mapView); _mapView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active = true; _mapView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; _mapView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active = true; _mapView.HeightAnchor.ConstraintEqualTo(View.HeightAnchor).Active = true; }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status == CLAuthorizationStatus.Denied) { SL.Manager.GetCityListWithLatitude(Platform.Lat, Platform.Lon, null); } }
//logic for locationmanager public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status != CLAuthorizationStatus.AuthorizedAlways) { NoAuth(this, EventArgs.Empty); } }
public static void LocationAuthCallback(CLAuthorizationStatus status) { if (locationDelegate != null) { locationDelegate(status); } }
public static AuthorizationState ToShared(this CLAuthorizationStatus status, bool isAlways) { var state = AuthorizationState.NotDetermined; switch (status) { case CLAuthorizationStatus.NotDetermined: break; case CLAuthorizationStatus.AuthorizedAlways: state = AuthorizationState.Authorized; break; case CLAuthorizationStatus.AuthorizedWhenInUse: state = isAlways ? AuthorizationState.NotDetermined : AuthorizationState.Authorized; break; case CLAuthorizationStatus.Restricted: case CLAuthorizationStatus.Denied: state = AuthorizationState.Denied; break; } return(state); }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status != CLAuthorizationStatus.NotDetermined) { _parent.FireLocationPermissionCompletionHandler(); } }
//from CLLocationManagerDelegate, if auth changes to always, start services public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status == CLAuthorizationStatus.AuthorizedAlways) { Start(); } }
/// <summary> /// Requests the always authorization. /// </summary> private void RequestAlwaysAuthorization() { CLAuthorizationStatus status = CLLocationManager.Status; if (status == CLAuthorizationStatus.AuthorizedWhenInUse || status == CLAuthorizationStatus.Denied) { string title = (status == CLAuthorizationStatus.Denied) ? "Location services are off" : "Background location is not enabled"; const string Message = "To use background location you must turn on 'Always' in the Location Services Settings"; var alertView = new UIAlertView(title, Message, null, "Cancel", "Settings"); alertView.Clicked += (sender, buttonArgs) => { if (buttonArgs.ButtonIndex == 1) { // Send the user to the Settings for this app var settingsUrl = new NSUrl(UIApplication.OpenSettingsUrlString); UIApplication.SharedApplication.OpenUrl(settingsUrl); } }; alertView.Show(); } else if (status == CLAuthorizationStatus.NotDetermined) { this.locationManager.RequestAlwaysAuthorization(); } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted) { StopListening(); TaskSource.TrySetException(new Exception(UNAUTHORISED_ERROR)); } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { // If user has services disabled, we're just going to throw an exception for consistency. if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted) { StopListening(); this.tcs.TrySetException(new GeolocationException(GeolocationError.Unauthorized)); } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { // If user has services disabled, we're just going to throw an exception for consistency. if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted) { StopListening(); _tcs.SetResult(OperationResult <Position> .AsFailure(new LocationException(LocationErrorType.Unauthorized))); } }
/// <summary> /// Authorizations the changed. /// </summary> /// <param name="manager">The manager.</param> /// <param name="status">The status.</param> public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { // If user has services disabled, we're just going to throw an exception for consistency. if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted) { StopListening(); _tcs.TrySetException(new GeolocationException(GeolocationError.Unauthorized)); } }
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) { Console.WriteLine ("containing iOS app's state {0}", UIApplication.SharedApplication.ApplicationState); status = CLLocationManager.Status; if (UIApplication.SharedApplication.ApplicationState == UIApplicationState.Active) SetupLocationManager (); return true; }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Console.WriteLine("containing iOS app's state {0}", UIApplication.SharedApplication.ApplicationState); status = CLLocationManager.Status; if (UIApplication.SharedApplication.ApplicationState == UIApplicationState.Active) { SetupLocationManager(); } return(true); }
protected virtual bool IsGoodStatus(CLAuthorizationStatus status, bool forBg) { if (forBg) { return(status == CLAuthorizationStatus.AuthorizedAlways); } return( status == CLAuthorizationStatus.Authorized || status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse ); }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status == CLAuthorizationStatus.Authorized || status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse) { tcsPermissions.TrySetResult(true); } else if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted) { tcsPermissions.TrySetResult(false); } }
public bool CheckLocationPermissions() { bool permissionsGranted = false; #if UNITY_ANDROID permissionsGranted = Permission.HasUserAuthorizedPermission(Permission.FineLocation); #elif UNITY_IOS CLAuthorizationStatus locationAuthorizationStatus = CocoaHelpersBridge.GetLocationAuthorizationStatus(); permissionsGranted = (locationAuthorizationStatus == CLAuthorizationStatus.AuthorizedAlways || locationAuthorizationStatus == CLAuthorizationStatus.AuthorizedWhenInUse); #endif Log.debug($"Location Permission : {permissionsGranted}"); return(permissionsGranted); }
void StartTrackingLocation() { CLAuthorizationStatus status = CLLocationManager.Status; if (status == CLAuthorizationStatus.NotDetermined) { locationManager.RequestWhenInUseAuthorization(); } else if (status == CLAuthorizationStatus.AuthorizedWhenInUse || status == CLAuthorizationStatus.AuthorizedAlways) { locationManager.StartUpdatingLocation(); } }
public void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { switch (status) { case CLAuthorizationStatus.AuthorizedAlways: case CLAuthorizationStatus.AuthorizedWhenInUse: _locationStatus.Invoke(_locationManager, new LocationCheckEventArgs(true)); break; case CLAuthorizationStatus.Denied: case CLAuthorizationStatus.Restricted: _locationStatus.Invoke(_locationManager, new LocationCheckEventArgs(false)); break; } }
void RequestAlwaysAuthorization() { if (!RequestLocationPermission) { return; } if (isPromptingLocationPermission) { return; } isPromptingLocationPermission = true; CLAuthorizationStatus status = CLLocationManager.Status; if (status == CLAuthorizationStatus.AuthorizedWhenInUse || status == CLAuthorizationStatus.Denied) { using (var pool = new NSAutoreleasePool()) { pool.InvokeOnMainThread(() => { UIAlertView alertView = new UIAlertView() { Title = (status == CLAuthorizationStatus.Denied) ? "Location services are off" : "Background location is not enabled", Message = "To use background location you must turn on 'Always' in the Location Services Settings" }; alertView.AddButton("OK"); alertView.Clicked += (sender, buttonArgs) => { if (buttonArgs.ButtonIndex == 1) { // Send the user to the Settings for this app NSUrl settingsUrl = new NSUrl(UIApplication.OpenSettingsUrlString); UIApplication.SharedApplication.OpenUrl(settingsUrl); } isPromptingLocationPermission = false; }; alertView.Show(); }); } } else if (status == CLAuthorizationStatus.NotDetermined) { locationManager.RequestAlwaysAuthorization(); } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { logger.Log($"iOS Authorization status changed: {status}"); if (!(status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse || status == CLAuthorizationStatus.Authorized) && status != CLAuthorizationStatus.NotDetermined) { var alertController = UIAlertController.Create(null, "We couldn't gain access to your location!", UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alertController, true, null); requestPrivilegesTaskCompletionSource?.TrySetResult(true); } if (status == CLAuthorizationStatus.Authorized || status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse) { requestPrivilegesTaskCompletionSource?.TrySetResult(true); } }
public void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (!selectedLocationCellIndex.HasValue) { return; } int index = selectedImageCellIndex.Value; var indexPath = NSIndexPath.FromRowSection(index, 0); var cell = (LocationFieldTableViewCell)TableView.CellAt(indexPath); cell.LookUpButton.Enabled = status != CLAuthorizationStatus.Denied; if (status == CLAuthorizationStatus.AuthorizedWhenInUse) { RequestLocationForCell(cell); } }
void OnAuthorizationChanged(object sender, CLAuthorizationChangedEventArgs e) { authorizationStatus = e.Status; switch (authorizationStatus) { case CLAuthorizationStatus.AuthorizedAlways: locationManager.StartUpdatingLocation(); break; case CLAuthorizationStatus.NotDetermined: locationManager.RequestAlwaysAuthorization(); break; default: break; } }
void OnAuthorizationChanged (object sender, CLAuthorizationChangedEventArgs e) { Console.WriteLine ("new authorization state = {0}", status); status = e.Status; switch (status) { case CLAuthorizationStatus.AuthorizedAlways: locationManager.StartUpdatingLocation (); break; case CLAuthorizationStatus.NotDetermined: locationManager.RequestAlwaysAuthorization (); break; default: break; } }
void OnAuthorizationChanged(object sender, CLAuthorizationChangedEventArgs e) { Console.WriteLine("new authorization state = {0}", status); status = e.Status; switch (status) { case CLAuthorizationStatus.AuthorizedAlways: locationManager.StartUpdatingLocation(); break; case CLAuthorizationStatus.NotDetermined: locationManager.RequestAlwaysAuthorization(); break; default: break; } }
private static GeolocationAccessStatus TranslateStatus(CLAuthorizationStatus status) { switch (status) { // These two constants are set by value based on https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/c/tdef/CLAuthorizationStatus // This is for the compatibility with iOS 8 and the introduction of AuthorizedWhenInUse. // This can be replaced with proper enum values when upgrading to iOS 8.0 SDK. case (CLAuthorizationStatus)4: // CLAuthorizationStatus.AuthorizedWhenInUse: case (CLAuthorizationStatus)3: // CLAuthorizationStatus.AuthorizedAlways: return(GeolocationAccessStatus.Allowed); case CLAuthorizationStatus.NotDetermined: return(GeolocationAccessStatus.Unspecified); default: case CLAuthorizationStatus.Restricted: case CLAuthorizationStatus.Denied: return(GeolocationAccessStatus.Denied); } }
public Task <bool> RequestPermissionAsync() { TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); EventHandler <CLAuthorizationChangedEventArgs> authorizationChanged = null; try { if (CLLocationManager.Status != CLAuthorizationStatus.NotDetermined && !this.HasLocationPermission) { tcs.SetResult(false); } else { authorizationChanged = (sender, e) => { CLAuthorizationStatus update = e.Status; this.locationManager.AuthorizationChanged -= authorizationChanged; if (update == CLAuthorizationStatus.AuthorizedWhenInUse || update == CLAuthorizationStatus.AuthorizedAlways) { tcs.SetResult(true); } else { tcs.SetResult(false); } }; this.locationManager.AuthorizationChanged += authorizationChanged; this.locationManager.RequestWhenInUseAuthorization(); } } catch (Exception ex) { tcs.SetException(ex); this.locationManager.AuthorizationChanged -= authorizationChanged; this.locationManager.StopUpdatingLocation(); } return(tcs.Task); }
public static AccessState FromNative(this CLAuthorizationStatus status, bool background) { switch (status) { case CLAuthorizationStatus.Restricted: return(AccessState.Restricted); case CLAuthorizationStatus.Denied: return(AccessState.Denied); case CLAuthorizationStatus.AuthorizedWhenInUse: return(background ? AccessState.Restricted : AccessState.Available); case CLAuthorizationStatus.AuthorizedAlways: return(AccessState.Available); case CLAuthorizationStatus.NotDetermined: default: return(AccessState.Unknown); } }
public void CheckLocationServicesAuthorizationStatus(CLAuthorizationStatus status) { switch (status) { case CLAuthorizationStatus.NotDetermined: ShowAlert(DataClass.Location, "not determined"); break; case CLAuthorizationStatus.Restricted: ShowAlert(DataClass.Location, "restricted"); break; case CLAuthorizationStatus.Denied: ShowAlert(DataClass.Location, "denied"); break; case CLAuthorizationStatus.Authorized: ShowAlert(DataClass.Location, "granted"); break; } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { switch (status) { case CLAuthorizationStatus.NotDetermined: _owner.Permission = MvxLocationPermission.Unknown; break; case CLAuthorizationStatus.Restricted: case CLAuthorizationStatus.Denied: _owner.Permission = MvxLocationPermission.Denied; break; case CLAuthorizationStatus.AuthorizedAlways: case CLAuthorizationStatus.AuthorizedWhenInUse: _owner.Permission = MvxLocationPermission.Granted; break; default: throw new ArgumentOutOfRangeException(); } }
public override void RequestWhenInUseAuthorization() { RequestedStatus = CLAuthorizationStatus.AuthorizedWhenInUse; }
void OnAuthorizationChanged(object sender, CLAuthorizationChangedEventArgs e) { authorizationStatus = e.Status; switch (authorizationStatus) { case CLAuthorizationStatus.AuthorizedAlways: locationManager.StartUpdatingLocation (); break; case CLAuthorizationStatus.NotDetermined: locationManager.RequestAlwaysAuthorization (); break; default: break; } }
//logic for locationmanager public override void AuthorizationChanged (CLLocationManager manager, CLAuthorizationStatus status) { if (status != CLAuthorizationStatus.AuthorizedAlways) { NoAuth (this, EventArgs.Empty); } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (CLLocationManager.Status == CLAuthorizationStatus.AuthorizedAlways) { manager.StartMonitoringSignificantLocationChanges (); } }
public void CheckLocationServicesAuthorizationStatus (CLAuthorizationStatus status) { switch (status) { case CLAuthorizationStatus.NotDetermined: ShowAlert (DataClass.Location, "not determined"); break; case CLAuthorizationStatus.Restricted: ShowAlert (DataClass.Location, "restricted"); break; case CLAuthorizationStatus.Denied: ShowAlert (DataClass.Location, "denied"); break; case CLAuthorizationStatus.Authorized: ShowAlert (DataClass.Location, "granted"); break; } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { switch (status) { case CLAuthorizationStatus.NotDetermined: _owner.Permission = MvxLocationPermission.Unknown; break; case CLAuthorizationStatus.Restricted: case CLAuthorizationStatus.Denied: _owner.Permission = MvxLocationPermission.Denied; break; case CLAuthorizationStatus.AuthorizedAlways: case CLAuthorizationStatus.AuthorizedWhenInUse: _owner.Permission = MvxLocationPermission.Granted; break; default: throw new ArgumentOutOfRangeException(); } }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status != CLAuthorizationStatus.NotDetermined) { _parent.FireLocationPermissionCompletionHandler (); } }
void OnAuthorizationChanged (object sender, CLAuthorizationChangedEventArgs e) { Console.WriteLine ("new authorization state = {0}", e.Status); status = e.Status; locationManager.StartUpdatingLocation (); }
public CLAuthroziationChangedEventArgs(CLAuthorizationStatus status) : base(status) { }
public void AuthorizationChanged (CLLocationManager manager, CLAuthorizationStatus status) { locationManager.RequestLocation (); }
public override void LocationRoximityUsable(bool usable, CLAuthorizationStatus authStatus) { }
public override void RequestAlwaysAuthorization() { RequestedStatus = CLAuthorizationStatus.AuthorizedAlways; }
bool LocationAuthorizationStatusPermitsAccess(CLAuthorizationStatus authorizationStatus) { return authorizationStatus == CLAuthorizationStatus.Authorized || authorizationStatus == CLAuthorizationStatus.AuthorizedAlways || authorizationStatus == CLAuthorizationStatus.AuthorizedWhenInUse; }
public override void RequestWhenInUseAuthorization() { RequestedStatus = CLAuthorizationStatus.AuthorizedWhenInUse; }
public void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) => AuthorizationStatusChanged?.Invoke(this, new CLAuthorizationChangedEventArgs(status));
// protected virtual BeaconInitStatus GetBluetoothStatus() { // using (var cb = new CBCentralManager()) { // cb. // switch (cb.State) { // case CBCentralManagerState.Unauthorized: return BeaconInitStatus.PermissionDenied; // case CBCentralManagerState.Unsupported: return BeaconInitStatus.BluetoothMissing; // case CBCentralManagerState.PoweredOn: return BeaconInitStatus.Success; // case CBCentralManagerState.PoweredOff: return BeaconInitStatus.BluetoothOff; // default : return BeaconInitStatus.Unknown; // } // } // } protected virtual bool IsGoodStatus(CLAuthorizationStatus status, bool forBg) { if (forBg) return status == CLAuthorizationStatus.AuthorizedAlways; return ( status == CLAuthorizationStatus.Authorized || status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse ); }