diff --git a/plugin.xml b/plugin.xml
index 15aa864..d445604 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -25,6 +25,13 @@
+
+ UIBackgroundModes
+
+ location
+
+
+
diff --git a/src/ios/APPBackgroundMode.h b/src/ios/APPBackgroundMode.h
index 44dd44e..a5f87d1 100644
--- a/src/ios/APPBackgroundMode.h
+++ b/src/ios/APPBackgroundMode.h
@@ -9,6 +9,7 @@
#import
#import
+#import
@interface APPBackgroundMode : CDVPlugin
@@ -17,4 +18,6 @@
// Deaktiviert den Hintergrundmodus
- (void) deactivateMode;
+@property (nonatomic, strong) CLLocationManager* locationManager;
+
@end
\ No newline at end of file
diff --git a/src/ios/APPBackgroundMode.m b/src/ios/APPBackgroundMode.m
index 5edebb4..7340506 100644
--- a/src/ios/APPBackgroundMode.m
+++ b/src/ios/APPBackgroundMode.m
@@ -11,16 +11,42 @@
@implementation APPBackgroundMode
+@synthesize locationManager;
+
// Aktiviert den Hintergrundmodus
- (void) activateMode
{
+ if (!locationManager) {
+ locationManager = [[CLLocationManager alloc] init];
+ };
+#ifdef __IPHONE_6_0
+ locationManager.activityType = CLActivityTypeFitness;
+#endif
+
+ // Empfängt nur Nachrichten, wenn sich die Position um 1km geändert hat
+ locationManager.distanceFilter = 1000;
+ // Startet das Aktualisieren des Standpunktes
+ [locationManager startUpdatingLocation];
}
// Deaktiviert den Hintergrundmodus
- (void) deactivateMode
{
+ if (locationManager) {
+ [locationManager stopUpdatingLocation];
+ };
+}
+// Registriert sich für die (sleep/resume) Events und startet bzw. stoppt die Geo-Lokalisierung
+- (void) pluginInitialize
+{
+ if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(activateMode) name:UIApplicationDidEnterBackgroundNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deactivateMode) name:UIApplicationWillEnterForegroundNotification object:nil];
+ } else {
+ [self activateMode];
+ }
}
@end
\ No newline at end of file