-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
That way there’s no ambiguity about when you should call things like `+[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]`. In fact, that method is now deprecated because it’s so easy to call in the wrong place. Fixes #1535.
`MGLAccountManager` is now guaranteed to initialize without the code ever making any mention of it. It also is guaranteed to be set up before `MGLMapboxMetrics` but will definitely cause `MGLMapboxMetrics` to be set up on the main thread if the access token is set in Info.plist.
Makes IB designables aware of access tokens set via Info.plist.
Do we need to deprecate, vs. just pulling? We're still in beta. |
I want the compiler warning to say what the alternative is rather than "I don't know what you're talking about", but come to think of it, an UNAVAILABLE macro makes more sense, as it's unignorable. |
Made `+[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]` unavailable, with a message explaining what to do instead. Removed a commented-out call to that method. Only the environment for an access token if one hasn’t already been set in Info.plist.
Does it make sense to keep If we decide to remove |
With these changes, if you wanted to upload your project to GitHub, leave out your access token (#1404), and avoid accidentally checking in your access token after you develop locally, you could employ the following Run Script build phase in Xcode (add it anywhere after the Copy Bundle Resources build phase): token="$(cat ~/.mapbox)"
if [ "$token" ]; then
plutil -replace MGLMapboxAccessToken -string $token $TARGET_BUILD_DIR/$INFOPLIST_PATH
fi Then all you have to do is create a file .mapbox in your user folder that contains an access token and build and run. There’s no risk of ever checking in that hidden file, and no need to interact with |
I still see using If token security is a priority, the plist will be the go-to option, but if it's a lone developer or a private codebase, setting the token in code feels like the easiest path to me. Using the app delegate's |
@friedbunny, that would be an argument for keeping In any case, I think it’s fair to expect developers to modify their Info.plist, since you can do so within the project editor. It’s a rare app that can be developed without ever opening the project editor. @bsudekum, does React Native let you modify the Info.plist that customarily comes with a project? I’m thinking about obsoleting |
Ah, bleh on my late night reading comprehension. |
The message referred to `+[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]`, which is no longer available.
|
Unfortunately, |
From a react-native point of view it would not be a deal breaker, but it would be 👎 to have to set the access token in the plist. One of the goals/advantages of react-native is to keep out of xcode. |
OK, I’m definitely convinced that To clarify, the intent of this PR is not about keeping the access token private – it just happens to make that easier. Rather, the intent is to replace a tricky setup dance with something that looks more like plain-vanilla, all-UIKit development. Currently, if you want to implement the Metrics switch inside your app, rather than in Settings, you need to call |
Before merging this PR, I’m also going to create an |
With helpful instructions for migrating to Info.plist or the `MGLAccountManager` API.
The singleton `MGLAccountManager` wants to be the sole arbiter of the access token, but each instance of `mbgl::Map` (`mbgl::DefaultFileSource` in #1607) has its own copy of the access token. Now `MGLMapView` observes for changes to the `MGLAccountManager`’s access token and synchronizes `mbgl::Map` with it.
`accessToken` parameter was removed in #1553.
That way there’s no ambiguity about when you should call things like
+[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]
. In fact, that method is now deprecated because it’s so easy to call in the wrong place.Fixes #1535.
/cc @incanus @bleege