mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2025-12-11 08:53:23 +00:00
Only activate the background mode if the location service is available
This commit is contained in:
@@ -86,7 +86,7 @@ namespace Cordova.Extension.Commands
|
||||
/// </summary>
|
||||
public static void Activate ()
|
||||
{
|
||||
if (Geolocator == null && isEnabled)
|
||||
if (Geolocator == null && isEnabled && IsServiceAvailable())
|
||||
{
|
||||
Geolocator = new Geolocator();
|
||||
|
||||
@@ -109,5 +109,13 @@ namespace Cordova.Extension.Commands
|
||||
}
|
||||
|
||||
private static void geolocator_PositionChanged (Geolocator sender, PositionChangedEventArgs args) {}
|
||||
|
||||
/// </summary>
|
||||
/// Gibt an, ob der Lokalisierungsdienst verfügbar ist
|
||||
/// </summary>
|
||||
private static bool IsServiceAvailable()
|
||||
{
|
||||
return !(Geolocator.LocationStatus == PositionStatus.Disabled || Geolocator.LocationStatus == PositionStatus.NotAvailable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user