You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/09/09 02:09:48 UTC

[1/2] git commit: Revert CB-6911 partially (keeping Info.plist key installation for iOS 8)

Repository: cordova-plugin-geolocation
Updated Branches:
  refs/heads/master 1c18ea079 -> 4102a332b


Revert CB-6911 partially (keeping Info.plist key installation for iOS 8)


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/3bc05a42
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/3bc05a42
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/3bc05a42

Branch: refs/heads/master
Commit: 3bc05a423d064413d6d15e68e4f14417d823318c
Parents: 1c18ea0
Author: Shazron Abdullah <sh...@apache.org>
Authored: Mon Sep 8 17:00:35 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Sep 8 17:00:35 2014 -0700

----------------------------------------------------------------------
 src/ios/CDVLocation.m | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/3bc05a42/src/ios/CDVLocation.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocation.m b/src/ios/CDVLocation.m
index ffb9714..f6f47a2 100644
--- a/src/ios/CDVLocation.m
+++ b/src/ios/CDVLocation.m
@@ -122,11 +122,6 @@
     // first stop, and then start the updating to ensure we get at least one
     // update, even if our location did not change.
     [self.locationManager stopUpdatingLocation];
-    
-    if (IsAtLeastiOSVersion(@"8.0")) {
-        [self.locationManager performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0];
-    }
-    
     [self.locationManager startUpdatingLocation];
     __locationStarted = YES;
     if (enableHighAccuracy) {


[2/2] git commit: CB-7158 - Fix geolocation for ios 8

Posted by sh...@apache.org.
CB-7158 - Fix geolocation for ios 8

Signed-off-by: Shazron Abdullah <sh...@apache.org>


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/4102a332
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/4102a332
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/4102a332

Branch: refs/heads/master
Commit: 4102a332b0c6b0c3513370a4c030a32e46a51e10
Parents: 3bc05a4
Author: Wei Li <we...@feedhenry.com>
Authored: Thu Aug 7 18:36:36 2014 +0100
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Sep 8 17:00:52 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/4102a332/src/ios/CDVLocation.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVLocation.m b/src/ios/CDVLocation.m
index f6f47a2..7c73b64 100644
--- a/src/ios/CDVLocation.m
+++ b/src/ios/CDVLocation.m
@@ -73,6 +73,11 @@
 
     if (authorizationStatusClassPropertyAvailable) {
         NSUInteger authStatus = [CLLocationManager authorizationStatus];
+#ifdef __IPHONE_8_0
+        if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {  //iOS 8.0+
+            return (authStatus == kCLAuthorizationStatusAuthorizedWhenInUse) || (authStatus == kCLAuthorizationStatusAuthorizedAlways) || (authStatus == kCLAuthorizationStatusNotDetermined);
+        }
+#endif
         return (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined);
     }
 
@@ -118,6 +123,21 @@
         return;
     }
 
+#ifdef __IPHONE_8_0
+    NSUInteger code = [CLLocationManager authorizationStatus];
+    if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) { //iOS8+
+        __highAccuracyEnabled = enableHighAccuracy;
+        if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]){
+            [self.locationManager requestAlwaysAuthorization];
+        } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) {
+            [self.locationManager  requestWhenInUseAuthorization];
+        } else {
+            NSLog(@"[Warning] No NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key is defined in the Info.plist file.");
+        }
+        return;
+    }
+#endif
+    
     // Tell the location manager to start notifying us of location updates. We
     // first stop, and then start the updating to ensure we get at least one
     // update, even if our location did not change.
@@ -324,6 +344,14 @@
     __locationStarted = NO;
 }
 
+//iOS8+
+-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
+{
+    if(!__locationStarted){
+        [self startLocation:__highAccuracyEnabled];
+    }
+}
+
 - (void)dealloc
 {
     self.locationManager.delegate = nil;