---
title: "MTConfig | Mobile sdk | Mobile sdk ios | Ios"
description: "Object representing the SDK global settings."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTConfig

```
public actor MTConfig
```

Object representing the SDK global settings.

Exposes properties and options such as API Key and caching preferences.

-   `[shared](#/s:11MapTilerSDK8MTConfigC6sharedACvpZ)`
    
    Undocumented
    
    #### Declaration
    
    Swift
    
    ```
    public static let shared: MTConfig
    ```
    
-   `[version](#/s:11MapTilerSDK8MTConfigC7versionSSvpZ)`
    
    SDK version
    
    #### Declaration
    
    Swift
    
    ```
    public static let version: String
    ```
    
-   `[logLevel](#/s:11MapTilerSDK8MTConfigC8logLevelAA05MTLogF0Ovp)`
    
    SDK log level.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var logLevel: MTLogLevel { get }
    ```
    
-   `[isCachingEnabled](#/s:11MapTilerSDK8MTConfigC16isCachingEnabledSbvp)`
    
    Boolean indicating whether caching is enabled.
    
    Note
    
    Defaults to true.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var isCachingEnabled: Bool { get }
    ```
    
-   `[isSessionLogicEnabled](#/s:11MapTilerSDK8MTConfigC21isSessionLogicEnabledSbvp)`
    
    Boolean indicating whether session logic is enabled.
    
    This allows MapTiler to enable “session based billing”.
    
    Note
    
    Defaults to true.
    
    See also
    
    `https://docs.maptiler.com/guides/maps-apis/maps-platform/what-is-map-session-in-maptiler-cloud/`
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var isSessionLogicEnabled: Bool { get }
    ```
    
-   `[isTelemetryEnabled](#/s:11MapTilerSDK8MTConfigC18isTelemetryEnabledSbvp)`
    
    Boolean indicating whether telemetry is enabled.
    
    The telemetry is very valuable to the team at MapTiler because it shares information about where to add the extra effort. It also helps spotting some incompatibility issues that may arise between the SDK and a specific version of a module. It consist in sending the SDK version, API Key, MapTiler session ID, if tile caching is enabled, if language specified at initialization, if terrain is activated at initialization, if globe projection is activated at initialization.
    
    Note
    
    Defaults to true.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var isTelemetryEnabled: Bool { get }
    ```
    
-   `[setLogLevel(_:)](#/s:11MapTilerSDK8MTConfigC11setLogLevelyyAA05MTLogG0OF)`
    
    Sets the SDK log level.
    
    #### Declaration
    
    Swift
    
    ```
    public func setLogLevel(_ level: MTLogLevel)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>level</em></code></td><td><div><p>The desired SDK log level.</p></div></td></tr></tbody></table>
    
-   `[setAPIKey(_:for:)](#/s:11MapTilerSDK8MTConfigC9setAPIKey_3forySS_AA9MTMapViewCSgtF)`
    
    Sets the MapTiler API key.
    
    #### Declaration
    
    Swift
    
    ```
    public func setAPIKey(_ apiKey: String, for map: MTMapView? = nil)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>apiKey</em></code></td><td><div><p>The MapTiler API Key.</p></div></td></tr><tr><td><code><em>map</em></code></td><td><div><p>Map view to apply to.</p></div></td></tr></tbody></table>
    
-   `[getAPIKey()](#/s:11MapTilerSDK8MTConfigC9getAPIKeySSSgyF)`
    
    Returns the MapTiler API key.
    
    #### Declaration
    
    Swift
    
    ```
    public func getAPIKey() -> String?
    ```
    
-   `[getMaptilerSessionId()](#/s:11MapTilerSDK8MTConfigC20getMaptilerSessionIdSSSgyF)`
    
    Returns the current MapTiler session ID.
    
    #### Declaration
    
    Swift
    
    ```
    public func getMaptilerSessionId() -> String?
    ```
    
-   `[setCaching(_:for:)](#/s:11MapTilerSDK8MTConfigC10setCaching_3forySb_AA9MTMapViewCtF)`
    
    Sets the caching mechanism.
    
    Note
    
    Enabled by default
    
    #### Declaration
    
    Swift
    
    ```
    public func setCaching(_ isEnabled: Bool, for map: MTMapView)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>isEnabled</em></code></td><td><div><p>Boolean indicating whether caching is enabled.</p></div></td></tr><tr><td><code><em>map</em></code></td><td><div><p>Map view to apply to.</p></div></td></tr></tbody></table>
    
-   `[setSessionLogic(_:for:)](#/s:11MapTilerSDK8MTConfigC15setSessionLogic_3forySb_AA9MTMapViewCtF)`
    
    Sets the session logic.
    
    Make sure to call before map init or use MTMapOptions to supply before map init.
    
    Note
    
    Enabled by default
    
    See also
    
    `https://docs.maptiler.com/guides/maps-apis/maps-platform/what-is-map-session-in-maptiler-cloud/`
    
    #### Declaration
    
    Swift
    
    ```
    public func setSessionLogic(_ isEnabled: Bool, for map: MTMapView)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>isEnabled</em></code></td><td><div><p>Boolean indicating whether session logic is enabled.</p></div></td></tr><tr><td><code><em>map</em></code></td><td><div><p>Map view to apply to.</p></div></td></tr></tbody></table>
    
-   `[setUnit(_:for:)](#/s:11MapTilerSDK8MTConfigC7setUnit_3foryAA6MTUnitO_AA9MTMapViewCtF)`
    
    Sets the unit of measurement.
    
    Note
    
    Default: .metric
    
    #### Declaration
    
    Swift
    
    ```
    public func setUnit(_ unit: MTUnit, for map: MTMapView)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>unit</em></code></td><td><div><p>The MTUnit type.</p></div></td></tr><tr><td><code><em>map</em></code></td><td><div><p>Map view to apply to.</p></div></td></tr></tbody></table>
    
-   `[getUnit()](#/s:11MapTilerSDK8MTConfigC7getUnitAA6MTUnitOSgyF)`
    
    Returns the unit of measurement.
    
    #### Declaration
    
    Swift
    
    ```
    public func getUnit() -> MTUnit?
    ```
    
-   `[setOfflineMaxTileCount(_:)](#/s:11MapTilerSDK8MTConfigC22setOfflineMaxTileCountyySiF)`
    
    Sets the maximum number of tiles allowed for a single offline region download. This prevents users from accidentally downloading massive areas that consume too much storage. Note: MapTiler enforces an internal safety limit (currently 15,000 tiles). If you provide a value higher than the internal limit, the internal limit will be enforced.
    
    #### Declaration
    
    Swift
    
    ```
    public func setOfflineMaxTileCount(_ maxTileCount: Int)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>maxTileCount</em></code></td><td><div><p>The maximum allowed tiles (default is 15,000).</p></div></td></tr></tbody></table>
    
-   `[setTelemetry(_:for:)](#/s:11MapTilerSDK8MTConfigC12setTelemetry_3forySb_AA9MTMapViewCtF)`
    
    Sets the telemetry.
    
    Note
    
    Enabled by default
    
    #### Declaration
    
    Swift
    
    ```
    public func setTelemetry(_ isEnabled: Bool, for map: MTMapView)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>isEnabled</em></code></td><td><div><p>Boolean indicating whether telemetry is enabled.</p></div></td></tr><tr><td><code><em>map</em></code></td><td><div><p>Map view to apply to.</p></div></td></tr></tbody></table>
    
-   `[handleEventsForBackgroundURLSession(identifier:completionHandler:)](#/s:11MapTilerSDK8MTConfigC35handleEventsForBackgroundURLSession10identifier17completionHandlerySS_yyctFZ)`
    
    Handles events for the background URLSession. Call this from your AppDelegate’s `application(_:handleEventsForBackgroundURLSession:completionHandler:)`
    
    #### Declaration
    
    Swift
    
    ```
    public static func handleEventsForBackgroundURLSession(
        identifier: String,
        completionHandler: @escaping () -> Void
    )
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>identifier</em></code></td><td><div><p>The identifier of the URLSession.</p></div></td></tr><tr><td><code><em>completionHandler</em></code></td><td><div><p>The completion handler provided by the app delegate.</p></div></td></tr></tbody></table>
