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

added banner to notify user to enable precise location during turn-by-turn navigation #2693

Merged
merged 7 commits into from
Nov 4, 2020

Conversation

jill-cardamon
Copy link
Contributor

@jill-cardamon jill-cardamon commented Oct 13, 2020

Added banner to notify a user to enable precise location during turn-by-turn navigation using CLLocationManager and locationDidChangeAuthorization(..), bringing this value up the delegate chain. Banner displays for 9 seconds (about the time it takes for a user to notice the banner and change their settings).

  • Add banner
  • Add notifications
  • Make this work on Xcode 11
  • Update changelog

Simulator Screen Shot - iPhone 8 - 2020-10-13 at 14 37 43

fix #2555
/cc @mapbox/navigation-ios

@jill-cardamon jill-cardamon added feature New feature request. topic: location labels Oct 13, 2020
@jill-cardamon jill-cardamon added this to the v1.2.0 milestone Oct 13, 2020
@jill-cardamon jill-cardamon self-assigned this Oct 13, 2020
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested changelog entry:

  • Added the NavigationServiceDelegate.navigationServiceDidChangeAuthorization(_:) method to find out when the user changes the application’s Location Services permissions. (#2693)

…ontroller to optional downcasting, changed PassiveLocationManager to use fullAccuracy instead of forced downcasting
@@ -367,6 +367,7 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
showStatus(title: title, spinner: false, duration: 3, animated: true, interactive: false)
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the extra white space.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!


if #available(iOS 14.0, *), accuracyAuthorization == .reducedAccuracy {
let title = NSLocalizedString("ENABLE_PRECISE_LOCATION", bundle: .mapboxNavigation, value: "Enable precise location to navigate", comment: "Label indicating precise location is off and needs to be turned on to navigate")
showStatus(title: title, spinner: false, duration: 20, animated: true, interactive: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make this status stay up until precise location is enabled, or is that the focus of another issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging, please open an issue to track persisting this banner until precise location is reenabled, so that we don’t lose track of that important detail. #2691 is sort of related, but I think persisting the accuracy authorization banner and automatically hiding it at the right time would be more tractable, because we’re already observing the notification that we need to observe to know when to hide the banner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaximAlien MaximAlien added iOS UI Work related to visual components, Android Auto, Camera, 3D, voice, etc. labels Oct 30, 2020
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is almost there, but there are a few more things to take care of before merging.

/**
Posted when user changes location authorization settings.

The user info dictionary indicates which keys and values changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The user info dictionary indicates which keys and values changed.
The user info dictionary contains the key `MapboxNavigationService.NotificationUserInfoKey.locationAuthorizationKey`.

}

/**
A key in the user info dictionary of a `Notification.Name.locationAuthorizationDidChange` notification. The corresponding value is a `Int` object the current location authorization setting. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s technically an Int when we put it in the dictionary, due to our internal workaround, but the developer would be expected to cast it to a CLAccuracyAuthorization.

If the developer needs to similarly work around the lack of CLAccuracyAuthorization on iOS 13, they’d conditionally implement an enumeration on iOS 13 that would match a typedef on iOS 14. But documenting that workaround is probably outside the scope of the documentation here, since the workaround requires a modicum of Objective-C code that might not be appropriate for every application.

Suggested change
A key in the user info dictionary of a `Notification.Name.locationAuthorizationDidChange` notification. The corresponding value is a `Int` object the current location authorization setting. */
A key in the user info dictionary of a `Notification.Name.locationAuthorizationDidChange` notification. The corresponding value is a `CLAccuracyAuthorization` indicating the current location authorization setting. */


if #available(iOS 14.0, *), accuracyAuthorization == .reducedAccuracy {
let title = NSLocalizedString("ENABLE_PRECISE_LOCATION", bundle: .mapboxNavigation, value: "Enable precise location to navigate", comment: "Label indicating precise location is off and needs to be turned on to navigate")
showStatus(title: title, spinner: false, duration: 20, animated: true, interactive: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging, please open an issue to track persisting this banner until precise location is reenabled, so that we don’t lose track of that important detail. #2691 is sort of related, but I think persisting the accuracy authorization banner and automatically hiding it at the right time would be more tractable, because we’re already observing the notification that we need to observe to know when to hide the banner.

…ationUserInfoKey struct, fixed CoreConstants comments to be more clear to developers
@jill-cardamon jill-cardamon merged commit e50fa90 into main Nov 4, 2020
@jill-cardamon jill-cardamon deleted the jill-enable-precise-location-status-bar-2555 branch November 4, 2020 20:06
@jill-cardamon jill-cardamon restored the jill-enable-precise-location-status-bar-2555 branch November 4, 2020 20:13
@jill-cardamon jill-cardamon deleted the jill-enable-precise-location-status-bar-2555 branch November 4, 2020 20:18
@jill-cardamon
Copy link
Contributor Author

Fixed a change (commit hash: 9295eb9) that I accidentally deleted.

@1ec5 1ec5 modified the milestones: v1.2.0, v1.1.0 Nov 10, 2020
1ec5 added a commit that referenced this pull request Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request. topic: location UI Work related to visual components, Android Auto, Camera, 3D, voice, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indicate reduced accuracy location mode
5 participants