public static async Task <AccessState> RequestAccess(this CLLocationManager locationManager, bool background) { var status = locationManager.GetCurrentStatus(background); if (status == AccessState.Available) { return(status); } var task = locationManager .WhenAccessStatusChanged(background) .StartWith() .Take(1) .ToTask(); #if __IOS__ if (background) { locationManager.RequestAlwaysAuthorization(); } else { locationManager.RequestWhenInUseAuthorization(); } #elif !__TVOS__ locationManager.RequestAlwaysAuthorization(); #endif status = await task; return(status); }
public static async Task <AccessState> RequestAccess(this CLLocationManager locationManager, bool background) { var status = locationManager.GetCurrentStatus(background); if (status != AccessState.Unknown) { return(status); } var task = locationManager .WhenAccessStatusChanged(background) .Take(1) .ToTask(); if (background) { locationManager.RequestAlwaysAuthorization(); } else { locationManager.RequestWhenInUseAuthorization(); } status = await task; return(status); }
public static async Task <AccessState> RequestAccess(this CLLocationManager locationManager, bool background) { var status = locationManager.GetCurrentStatus(background); if (status != AccessState.Unknown) { return(status); } var task = locationManager .WhenAccessStatusChanged(background) .StartWith() .Take(1) .ToTask(); //#if __IOS__ if (background) { locationManager.RequestAlwaysAuthorization(); } else { locationManager.RequestWhenInUseAuthorization(); } //#elif !__TVOS__ // locationManager.RequestAlwaysAuthorization(); //#endif status = await task.ConfigureAwait(false); return(status); }
public static async Task <AccessState> RequestAccess(this CLLocationManager locationManager, bool background) { var status = locationManager.GetCurrentStatus(background); if (status != AccessState.Unknown) { return(status); } status = await locationManager .WhenAccessStatusChanged(background) .Take(1) .ToTask(); return(status); }