mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2025-12-13 01:43:24 +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>
|
/// </summary>
|
||||||
public static void Activate ()
|
public static void Activate ()
|
||||||
{
|
{
|
||||||
if (Geolocator == null && isEnabled)
|
if (Geolocator == null && isEnabled && IsServiceAvailable())
|
||||||
{
|
{
|
||||||
Geolocator = new Geolocator();
|
Geolocator = new Geolocator();
|
||||||
|
|
||||||
@@ -109,5 +109,13 @@ namespace Cordova.Extension.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void geolocator_PositionChanged (Geolocator sender, PositionChangedEventArgs args) {}
|
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