From 92d9308eb8a996ad2d85268e36fc04caeec8f5d6 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 21 Jul 2015 18:09:48 -0400 Subject: [PATCH 1/4] Ask for 'always' location permissions, too --- platform/ios/MGLMapView.mm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index cdd3044dc..5ed9d9200 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -2214,7 +2214,15 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) [NSException raise:@"Missing Location Services usage description" format: @"In iOS 8 and above, this app must have a value for NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in its Info.plist."]; } - [self.locationManager requestWhenInUseAuthorization]; + // request location permissions, if both keys exist ask for less permissive + if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) + { + [self.locationManager requestWhenInUseAuthorization]; + } + else if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]) + { + [self.locationManager requestAlwaysAuthorization]; + } } #endif From 4977858f4d5cc181ab8204c472b3ee84c37245a4 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 22 Jul 2015 11:41:58 -0400 Subject: [PATCH 2/4] Fix testUserTrackingModeFollow test to accept location permissions ask I thought that the tests were bypassing the permissions dialog, but it turns out that was only half correct: we were not actually asking for `always` location permission in MBGL. --- test/ios/MapViewTests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m index fadbbae60..f4ae501d7 100644 --- a/test/ios/MapViewTests.m +++ b/test/ios/MapViewTests.m @@ -544,7 +544,7 @@ - (void)testUserTrackingModeFollow { tester.mapView.userTrackingMode = MGLUserTrackingModeFollow; - [tester waitForTimeInterval:1]; + [tester acknowledgeSystemAlert]; XCTAssertEqual(tester.mapView.userLocationVisible, YES, @@ -570,7 +570,7 @@ - (void)testUserTrackingModeFollowWithHeading { tester.mapView.userTrackingMode = MGLUserTrackingModeFollowWithHeading; - [tester waitForTimeInterval:1]; + [tester acknowledgeSystemAlert]; XCTAssertEqual(tester.mapView.userLocationVisible, YES, From 3643053cb413c3f8289be9e5d183218fb314b310 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 25 Aug 2015 16:00:44 -0700 Subject: [PATCH 3/4] Bump metrics tests timeouts EVERYWHERE --- test/ios/MetricsTests.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ios/MetricsTests.m b/test/ios/MetricsTests.m index cd02c2d52..d3b99dc63 100644 --- a/test/ios/MetricsTests.m +++ b/test/ios/MetricsTests.m @@ -119,7 +119,7 @@ const NSTimeInterval MGLFlushInterval = 60; [[MGLMapboxEvents sharedManager] flush]; - [self waitForExpectationsWithTimeout:1.0 handler:nil]; + [self waitForExpectationsWithTimeout:2.0 handler:nil]; XCTAssertNil([[MGLMapboxEvents sharedManager] timer]); } @@ -143,7 +143,7 @@ const NSTimeInterval MGLFlushInterval = 60; id eventsMock = [OCMockObject partialMockForObject:[MGLMapboxEvents sharedManager]]; [[[eventsMock expect] andForwardToRealObject] startTimer]; [self pushFakeEvent]; - [eventsMock verifyWithDelay:0.5]; + [eventsMock verifyWithDelay:2.0]; XCTAssertEqual([[[MGLMapboxEvents sharedManager] eventQueue] count], 1); XCTAssertNotNil([[MGLMapboxEvents sharedManager] timer]); @@ -164,7 +164,7 @@ const NSTimeInterval MGLFlushInterval = 60; [[MGLMapboxEvents sharedManager] flush]; - [self waitForExpectationsWithTimeout:1.0 handler:nil]; + [self waitForExpectationsWithTimeout:2.0 handler:nil]; [self pushFakeEvent]; id eventsMock = [OCMockObject partialMockForObject:[MGLMapboxEvents sharedManager]]; @@ -178,7 +178,7 @@ const NSTimeInterval MGLFlushInterval = 60; id eventsMock = [OCMockObject partialMockForObject:[MGLMapboxEvents sharedManager]]; [[eventsMock expect] postEvents:events]; [[MGLMapboxEvents sharedManager] flush]; - [eventsMock verifyWithDelay:1.0]; + [eventsMock verifyWithDelay:2.0]; XCTAssertTrue([[[MGLMapboxEvents sharedManager] eventQueue] count] == 0); } @@ -209,7 +209,7 @@ const NSTimeInterval MGLFlushInterval = 60; [self pushFakeEvent]; [MGLMapboxEvents flush]; - [self waitForExpectationsWithTimeout:1.0 handler:nil]; + [self waitForExpectationsWithTimeout:2.0 handler:nil]; } - (void)testPushEventAddsToEventQueue { From 2f30dfe97d851f2a2bb4141dc234013b01f8afd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 25 Aug 2015 15:27:23 -0700 Subject: [PATCH 4/4] Disable heading updates for .FollowWithCourse Fixes #2180. --- platform/ios/MGLMapView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 5ed9d9200..f12836b05 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -2310,6 +2310,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) break; } case MGLUserTrackingModeFollow: + case MGLUserTrackingModeFollowWithCourse: { self.showsUserLocation = YES; @@ -2323,7 +2324,6 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) break; } case MGLUserTrackingModeFollowWithHeading: - case MGLUserTrackingModeFollowWithCourse: { self.showsUserLocation = YES;