MGLAccountManager


@interface MGLAccountManager : NSObject

The MGLAccountManager object provides a global way to set a Mapbox API access token.

  • Set the Mapbox access token to be used by all instances of MGLMapView in the current application.

    Mapbox-hosted vector tiles and styles require an API access token, which you can obtain from the Mapbox account page. Access tokens associate requests to Mapbox’s vector tile and style APIs with your Mapbox account. They also deter other developers from using your styles without your permission.

    Note

    You must set the access token before attempting to load any Mapbox-hosted style. Therefore, you should generally set it before creating an instance of MGLMapView. The recommended way to set an access token is to add an entry to your application’s Info.plist file with the key MGLMapboxAccessToken and the type String. Alternatively, you may call this method from your application delegate’s -applicationDidFinishLaunching: method.

    Declaration

    Objective-C

    + (void)setAccessToken:(nullable NSString *)accessToken;

    Swift

    class func setAccessToken(_ accessToken: String?)

    Parameters

    accessToken

    A Mapbox access token. Calling this method with a value of nil has no effect.

  • Returns the Mapbox access token in use by instances of MGLMapView in the current application.

    Declaration

    Objective-C

    + (nullable NSString *)accessToken;

    Swift

    class func accessToken() -> String?