mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Merge MGLNetworkConfiguration into MGLAccountManager

Open 1ec5 opened this issue 6 years ago • 5 comments

MGLNetworkConfiguration is a singleton that currently does nothing but store the result of looking up the Info.plist’s MGLMapboxAPIBaseURL value. But calling -[NSBundle objectForInfoDictionaryKey:] is really fast, so fast that we could inline the call to -[MGLNetworkConfiguration apiBaseURL:] without affecting performance in an appreciable way.

That said, there is an unused -setAPIBaseURL: method. The ability to set the API base URL on the fly at runtime could be useful for the same reason that the -[MGLMapboxAccountManager setAccessToken:] method is sometimes useful. We don’t guarantee that the developer can swap access tokens out from under an existing map view, but the method does give the developer some flexibility in choosing when to initialize the SDK.

An access token is meaningless without an accompanying API base URL, so we could merge MGLNetworkConfiguration into MGLAccountManager and make the apiBaseURL property public. The Info.plist key would remain as the preferred way to set the API base URL.

/ref https://github.com/mapbox/mapbox-gl-native/pull/6709#issuecomment-253942073 /cc @lloydsheng @m-stephen

1ec5 avatar Jul 18 '18 01:07 1ec5

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Jan 14 '19 03:01 stale[bot]

I am working on this in https://github.com/mapbox/mapbox-gl-native/pull/13754.

Because the events library reads the API base URL from the Info.plist, it may not be aware if users do set the API base URL programmatically.

cc @rclee

jmkiley avatar Jan 18 '19 00:01 jmkiley

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Jul 17 '19 10:07 stale[bot]

We’ve extended MGLNetworkConfiguration a tiny bit since the opening of this issue, but it seems like something that should still be considered.

friedbunny avatar Jul 17 '19 17:07 friedbunny

By way of an update, #13754 moved the code that reads MGLMapboxAPIBaseURL from the Info.plist from MGLNetworkConfiguration to MGLAccountManager. However, MGLAccountManager.apiBaseURL remains private, and MGLNetworkConfiguration remains and has taken on additional functionality.

1ec5 avatar Oct 28 '21 17:10 1ec5