Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PassiveLocationManager should implement iOS 14 authorization #2554

Closed
1ec5 opened this issue Aug 19, 2020 · 3 comments · Fixed by #2649
Closed

PassiveLocationManager should implement iOS 14 authorization #2554

1ec5 opened this issue Aug 19, 2020 · 3 comments · Fixed by #2649
Assignees
Labels
release blocker Needs to be resolved before the release. topic: location
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Aug 19, 2020

mapbox/mapbox-gl-native-ios#361 and mapbox/mapbox-gl-native-ios#376 added the MGLLocationManager.accuracyAuthorization property and the MGLLocationManager.requestTemporaryFullAccuracyAuthorization(withPurposeKey:) and MGLLocationManagerDelegate.locationManagerDidChangeAuthorization(_:) methods for consistency with Core Location’s members by the same name. PassiveLocationManager should implement these members for forward compatibility with map SDK v6.1.0 and iOS 14. Since -[CLLocationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:] and -[CLLocationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:completion:] both bridge to Swift as the same method, we’d probably need to implement MGLLocationManager.requestTemporaryFullAccuracyAuthorization(withPurposeKey:completionHandler:) with the completion handler.

These implementations would just be passthroughs to the underlying PassiveLocationDataSource.systemLocationManager.

At a glance, it doesn’t appear that any of the other location manager classes in this codebase will need to implement the new iOS 14 members:

  • NavigationLocationManager is used during active turn-by-turn navigation, which would automatically postpone authorizaton expiration to the end of the route, and it also enables background location updates when the application is properly configured for them.
  • The coarse location manager in CarPlayMapViewController.coarseLocationManager doesn’t need full accuracy, because it’s only used to determine whether a day or night style is more appropriate in the current time zone.
  • The coarse location manager in CarPlaySearchController.coarseLocationManager similarly doesn’t need full accuracy, because a difference of a few kilometers doesn’t impact Mapbox Geocoding API search results by much, if at all. This is also in an example application, so developers have the ability to request full accuracy for search if they need to.
  • ReplayLocationManager and SimulatedLocationManager don’t need actual locations from Core Location, let alone locations with full accuracy.

/cc @mapbox/navigation-ios @mapbox/maps-ios

@1ec5 1ec5 added this to the v1.0.0 milestone Aug 19, 2020
@1ec5 1ec5 added the release blocker Needs to be resolved before the release. label Aug 19, 2020
@1ec5 1ec5 self-assigned this Aug 24, 2020
@IodaMikeMapbox IodaMikeMapbox self-assigned this Aug 25, 2020
@IodaMikeMapbox
Copy link
Contributor

The MGLLocationManagerDelegate.locationManagerDidChangeAuthorization(_:) can't be called for now because we don't depend on maps with that method.

PassiveLocation's implementation of the MGLLocationManager.accuracyAuthorization can't be added without adding a restriction of using xcode 12 beta for building, because the compiler doesn't know CLAccuracyAuthorization enum.

@1ec5
Copy link
Contributor Author

1ec5 commented Aug 26, 2020

I had originally prioritized this issue for v1.0 thinking that map SDK v6.1.0 or v6.2.0 would come out including mapbox/mapbox-gl-native-ios#361, Carthage and CocoaPods users would automatically upgrade to it due to our use of the ~> operator for that dependency, and PassiveLocationManager would suddenly fail to conform to the MGLLocationManager protocol due to these missing members. However, now I realize that these new members are marked @optional.

That makes it less important to take care of this change for v1.0, but we should still do it in the v1.x timeframe ahead of when iOS 14 is released. We shouldn’t wait until we can start requiring Xcode 12 to build the SDK, nor until we can require iOS 14 to run the SDK. So we’ll need to find ways around the fact that these symbols don’t exist in Xcode 11 and the iOS 13 SDK.

The MGLLocationManagerDelegate.locationManagerDidChangeAuthorization(_:) can't be called for now because we don't depend on maps with that method.

It is possible to call this method anyways using perform(_:with:) after checking responds(to:).

PassiveLocation's implementation of the MGLLocationManager.accuracyAuthorization can't be added without adding a restriction of using xcode 12 beta for building, because the compiler doesn't know CLAccuracyAuthorization enum.

One workaround would be to define a similar typedef in an Objective-C header, conditionalizing it on __IPHONE_OS_VERSION_MAX_ALLOWED < 140000. That would be a bit unsightly but justifiable because we know what the signature is on iOS 14 and above.

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 22, 2020

However, now I realize that these new members are marked @optional.

Unfortunately, the map SDK calls this method without checking whether it’s implemented, causing a crash as soon as the map SDK’s built-in user location indicator updates for the first time (typically on launch): mapbox/mapbox-gl-native-ios#381 (comment).

mapbox/mapbox-gl-native-ios#470 tracks the underlying root cause, but this issue meanwhile is a release blocker, because we need to implement the functionality anyways for iOS 14 and can’t wait for a patch of the map SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release blocker Needs to be resolved before the release. topic: location
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants