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

Directions crash when accessToken is not provided - it should use token from MGLMapboxAccessToken #396

Open
wojciech-kulik opened this issue Dec 21, 2019 · 2 comments
Labels
backwards incompatible changes that break backwards compatibility of public API improvement Improvement for an existing feature.

Comments

@wojciech-kulik
Copy link

Steps to reproduce

  1. Set token using MGLAccountManager.accessToken = "123123"
  2. Create object Directions()

Expected behavior

Directions should be properly initialized with a token set using MGLAccountManager.accessToken if not provided via parameter or info.plist

Actual behavior

There is a crash. Check this internal implementation of init:

public init(accessToken: String?, host: String?) {
    let accessToken = accessToken ?? defaultAccessToken
    precondition(accessToken != nil && !accessToken!.isEmpty, "A Mapbox access token is required. Go to <https://account.mapbox.com/access-tokens/>. In Info.plist, set the MGLMapboxAccessToken key to your access token, or use the Directions(accessToken:host:) initializer.")    
    ...
}

it uses accessToken from parameter or defaultAccessToken which is the one from info.plist. However, it is not using MGLAccountManager.accessToken.

@wojciech-kulik
Copy link
Author

I was trying to add ?? MGLAccountManager.accessToken in init in Directions.swift but I see that you don't have access to the Mapbox module there.

@1ec5
Copy link
Contributor

1ec5 commented Dec 26, 2019

By design, MapboxDirections.swift doesn’t depend on the map SDK, though the navigation SDK does. If an application is already programmatically setting MGLAccountManager.accessToken, it can pass MGLAccountManager.accessToken (or the access token as a string literal) into the Directions(accessToken:host:) initializer.

@1ec5 1ec5 added backwards incompatible changes that break backwards compatibility of public API improvement Improvement for an existing feature. labels Dec 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible changes that break backwards compatibility of public API improvement Improvement for an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants