Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/permission check #333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Geolocator.Plugin/Abstractions/ListenerSettings.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ public class ListenerSettings
/// </summary>
public bool ShowsBackgroundLocationIndicator { get; set; } = false;

/// <summary>
/// A boolean indicating whether Always permission should be required to start location listening
/// </summary>
public bool RequireLocationAlwaysPermission { get; set; } = false;
}
}
8 changes: 5 additions & 3 deletions src/Geolocator.Plugin/Apple/GeolocatorImplementation.apple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ public async Task<IEnumerable<Address>> GetAddressesForPositionAsync(Position po
/// <param name="listenerSettings">Optional settings (iOS only)</param>
public async Task<bool> StartListeningAsync(TimeSpan minimumTime, double minimumDistance, bool includeHeading = false, ListenerSettings listenerSettings = null)
{


if (minimumDistance < 0)
throw new ArgumentOutOfRangeException(nameof(minimumDistance));

Expand All @@ -380,10 +378,14 @@ public async Task<bool> StartListeningAsync(TimeSpan minimumTime, double minimum
var hasPermission = false;
if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
{
if (listenerSettings.AllowBackgroundUpdates)
if (listenerSettings.RequireLocationAlwaysPermission)
{
hasPermission = await CheckAlwaysPermissions();
}
else
{
hasPermission = await CheckWhenInUsePermission();
}
}

if (!hasPermission)
Expand Down