Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Change MAPBOX_ACCESS_TOKEN on runtime #718

Open
taq opened this issue Nov 4, 2021 · 1 comment
Open

Change MAPBOX_ACCESS_TOKEN on runtime #718

taq opened this issue Nov 4, 2021 · 1 comment

Comments

@taq
Copy link

taq commented Nov 4, 2021

Hi!

As said on every doc about installation, we need to set MAPBOX_ACCESS_TOKEN on our build.gradle file, loading it from properties, ok ... but I need to change the token for a specific customer token, after the login process, is it possible?
While writing this I found a reference to setAccessToken, maybe is the right way? Is there any examples to use it with Kotlin on V10?
Thanks!

@taq taq changed the title Change MAPBOX_ACCESS_TOKEN dinamically Change MAPBOX_ACCESS_TOKEN on runtime Nov 4, 2021
@taq
Copy link
Author

taq commented Nov 5, 2021

I think I figured it out with V10:

https://docs.mapbox.com/android/maps/guides/migrate-to-v10/#default-resourceoptions-configurationincluding-access-token

// Set the application-scoped ResourceOptionsManager with customised token and tile store usage mode
// so that all MapViews created with default config will apply these settings.
ResourceOptionsManager.getDefault(this, getString(R.string.mapbox_access_token)).update {
  tileStoreUsageMode(TileStoreUsageMode.READ_ONLY)
}

I just was thinking that setDefault would be a better name (write to the defaults), but anyway, this way, as stated all resources (maps, routes) after that will use that specific token, right? Even if I use only:

ResourceOptionsManager.getDefault(this, getString(R.string.mapbox_access_token))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant