mapbox / mapbox/mapbox-directions-swift
Directions crash when accessToken is not provided - it should use token from MGLMapboxAccessToken
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 206
- Forks
- 99
- Avg merge
- 7h 54m
- Merged PRs (30d)
- 3
Description
### 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 . 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`.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to Directions.init(accessToken:host:) and its defaultAccessToken fallback; start there and inspect how MGLAccountManager.accessToken is exposed. Reproduce with MGLAccountManager.accessToken set and Directions() without a parameter, then verify initialization succeeds using that token.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100