Skip to content

Commit

Permalink
[Windows] Handle errors in request access (#1458)
Browse files Browse the repository at this point in the history
* Added catch all for geolocator.RequestAccessAsync()
 - this can throw errors if the Geolocation Service is disabled in Windows.

* updated version and changelog

---------

Co-authored-by: Dan Kane <[email protected]>
  • Loading branch information
daniel-kane-everbridge-com and Dan Kane authored Mar 14, 2024
1 parent ff0d225 commit 3b58610
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions geolocator_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.3

* Fixes crash under Windows when RequestAcess is called while the Geolocation Service is disabled. (#1455)

## 0.2.2

* Fixes crash under Windows when getCurrentPosition method is called. (#1240)
Expand Down
2 changes: 1 addition & 1 deletion geolocator_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: geolocator_windows
description: Geolocation Windows plugin for Flutter. This plugin provides the Windows implementation for the geolocator.
repository: https://github.com/baseflow/flutter-geolocators
issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen
version: 0.2.2
version: 0.2.3

environment:
sdk: ">=2.15.0 <4.0.0"
Expand Down
6 changes: 5 additions & 1 deletion geolocator_windows/windows/geolocator_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,13 @@ winrt::fire_and_forget GeolocatorPlugin::RequestAccessAsync(std::unique_ptr<Meth
result->Success(EncodableValue((int)LocationPermission::Denied));
else if(access == GeolocationAccessStatus::Unspecified)
result->Success(EncodableValue((int)LocationPermission::DeniedForever));
} catch(const std::exception& ex) {
}
catch(const std::exception& ex) {
result->Error(ErrorCodeToString(ErrorCode::PermissionDefinitionsNotFound), ex.what());
}
catch (...) {
result->Error(ErrorCodeToString(ErrorCode::UnknownError), "RequestAccess failed. Check the Geolocation Service is running.");
}
}

void GeolocatorPlugin::OnCheckPermission(std::unique_ptr<MethodResult<>> result) {
Expand Down

0 comments on commit 3b58610

Please sign in to comment.