cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] cordova-plugin-geolocation git commit: Update iOS geolocation plugin to avoid THREAD WARNING: ['Geolocation'], operation occurs in new Thread
Date Mon, 25 Apr 2016 20:54:26 GMT
Repository: cordova-plugin-geolocation
Updated Branches:
  refs/heads/master b298182c0 -> f14839990


Update iOS geolocation plugin to avoid THREAD WARNING: ['Geolocation'], operation occurs in
new Thread


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/8fbceca8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/8fbceca8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/8fbceca8

Branch: refs/heads/master
Commit: 8fbceca845441f4f421548f243d2f05573d11225
Parents: 79bdb04
Author: Guillaumedev <contact@guillaumedev.com>
Authored: Wed Jan 20 21:47:40 2016 +0100
Committer: Guillaumedev <contact@guillaumedev.com>
Committed: Wed Jan 20 21:47:40 2016 +0100

----------------------------------------------------------------------
 src/ios/CDVLocation.m | 54 ++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/8fbceca8/src/ios/CDVLocation.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocation.m b/src/ios/CDVLocation.m
index a7c0248..e4b34a1 100644
--- a/src/ios/CDVLocation.m
+++ b/src/ios/CDVLocation.m
@@ -192,35 +192,37 @@
 
 - (void)getLocation:(CDVInvokedUrlCommand*)command
 {
-    NSString* callbackId = command.callbackId;
-    BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];
-
-    if ([self isLocationServicesEnabled] == NO) {
-        NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
-        [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
-        [posError setObject:@"Location services are disabled." forKey:@"message"];
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsDictionary:posError];
-        [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-    } else {
-        if (!self.locationData) {
-            self.locationData = [[CDVLocationData alloc] init];
-        }
-        CDVLocationData* lData = self.locationData;
-        if (!lData.locationCallbacks) {
-            lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
-        }
+    [self.commandDelegate runInBackground:^{
+        NSString* callbackId = command.callbackId;
+        BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];
+
+        if ([self isLocationServicesEnabled] == NO) {
+            NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
+            [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
+            [posError setObject:@"Location services are disabled." forKey:@"message"];
+            CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsDictionary:posError];
+            [self.commandDelegate sendPluginResult:result callbackId:callbackId];
+        } else {
+            if (!self.locationData) {
+                self.locationData = [[CDVLocationData alloc] init];
+            }
+            CDVLocationData* lData = self.locationData;
+            if (!lData.locationCallbacks) {
+                lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
+            }
 
-        if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
-            // add the callbackId into the array so we can call back when get data
-            if (callbackId != nil) {
-                [lData.locationCallbacks addObject:callbackId];
+            if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
+                // add the callbackId into the array so we can call back when get data
+                if (callbackId != nil) {
+                    [lData.locationCallbacks addObject:callbackId];
+                }
+                // Tell the location manager to start notifying us of heading updates
+                [self startLocation:enableHighAccuracy];
+            } else {
+                [self returnLocationInfo:callbackId andKeepCallback:NO];
             }
-            // Tell the location manager to start notifying us of heading updates
-            [self startLocation:enableHighAccuracy];
-        } else {
-            [self returnLocationInfo:callbackId andKeepCallback:NO];
         }
-    }
+    }];
 }
 
 - (void)addWatch:(CDVInvokedUrlCommand*)command


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message