Package es.situm.sdk

Class Configuration

java.lang.Object
es.situm.sdk.Configuration

public class Configuration extends Object
Set the configuration of the the Situm SDK: user credentials, dashboard url, cache expiration, etc.
  • Method Details

    • setApiKey

      public boolean setApiKey(@NonNull String apiKey)
      Provides your API key to the Situm SDK for Android. This key is generated for your application in the Situm Dashboard. Any previously configured credentials will be replaced.

      The SDK will internally generate a stable, unique identifier derived from the provided apiKey. This identifier is used for internal SDK operations and does not expose the original API key.

      This method is the preferred way to configure authentication credentials in the SDK.

      Parameters:
      apiKey - API key obtained from the Situm Dashboard; must not be null or empty.
      Returns:
      true if the API key was successfully provided, false otherwise.
      Throws:
      IllegalArgumentException - if apiKey is null or empty.
    • setApiKey

      @Deprecated public boolean setApiKey(String email, @NonNull String apiKey)
      Deprecated.
      Use setApiKey(String) instead.
      Provides your API key to the Situm SDK for Android. This key is generated for your application in the Dashboard. Old credentials will be removed.

      Note: The email parameter is ignored in this implementation. The SDK will automatically generate a unique internal identifier based on the apiKey. This method is functionally equivalent to setApiKey(String) without an email.

      Parameters:
      email - ignored; can be null or any value.
      apiKey - API key obtained from the Situm Dashboard; must not be null or empty.
      Returns:
      true if the API key was successfully provided, false otherwise.
      Throws:
      IllegalArgumentException - if apiKey is null or empty.
    • setToken

      public boolean setToken(@NonNull String base64Token)
      Provides your token to the Situm SDK for Android. Any previously configured credentials will be replaced.

      The SDK does not cryptographically validate the token signature, nor does it verify the token against Situm servers when this method is called. The token is parsed locally only to obtain the account information needed by the SDK, and it will be sent as a Bearer token in subsequent authenticated network requests.

      If the provided token is expired, has an invalid signature, or is otherwise rejected by Situm servers, network operations that require server authentication will fail. However, features that can operate with already cached local data may continue to work, such as visualizing cached resources or positioning with previously downloaded positioning data.

      User-provided tokens cannot be renewed automatically by the SDK. To recover from an expired or rejected token, provide a new token by calling this method again.

      Parameters:
      base64Token - String representing the token used for authentication; must not be null or empty. The expected format is a base64-encoded JWT with header, payload and signature sections. This token can be retrieved from a REST endpoint.
      Returns:
      true if the token was successfully provided, false otherwise.
      Throws:
      IllegalArgumentException - if base64Token is null, empty or cannot be parsed.
    • currentEmailAccount

      @Nullable public String currentEmailAccount()
      Return user email of credentials previously provided with setApiKey(String, String), setUserPass(String, String) or declared in the Android Manifest
      Returns:
      null if SDK has no credentials, current email otherwise.
    • setUserPass

      public boolean setUserPass(@NonNull String email, @NonNull String password)
      Provides user's email and password. This credentials will be used to obtain a valid user token to authenticate the server request, when necessary. Token obtaining is not necessary done when this method is executed. Old credentials will be removed.
      Parameters:
      email - user's email. Can't be empty.
      password - user's password. Can't be empty.
      Returns:
      true if operation finished successfully, otherwise false
      Throws:
      IllegalArgumentException - if email or password are null or empty
    • allowInvalidSSLCertificate

      public boolean allowInvalidSSLCertificate(boolean allowInvalidSSLCertificate)
      Tell the system to trust the SSL certificate of the server (even though the Authority is not valid).
      This should not be used in production unless you really don't care about the security. Use at your own risk.
      Parameters:
      allowInvalidSSLCertificate - if true, communications with the server may not be secure
      Returns:
      true if operation finished successfully, otherwise false
    • isAllowInvalidSSLCertificate

      public boolean isAllowInvalidSSLCertificate()
      Returns true if all SSL certificates are trusted
      Returns:
      if true, the SDK will trust all SSL certificates and the communication with the server may not be secure
    • getDashboardURL

      @NonNull public String getDashboardURL()
      Obtains the currently Dashboard url used
      Returns:
      url used by the SDK
    • setDashboardURL

      public void setDashboardURL(@NonNull String url)
      Set the Dashboard URL used by the SDK
      Parameters:
      url - the new Dashboard url. It will do nothing if is null.
    • getCacheMaxAge

      public long getCacheMaxAge()
      Get the maximum age of a cached response.
      Returns:
      age of the cached response in milliseconds
    • setCacheMaxAge

      public boolean setCacheMaxAge(@IntRange(from=0L) long maxAge, @NonNull TimeUnit timeUnit)
      Sets the maximum age of a cached response. If the cache response's age exceeds maxAge, it will not be used and a network request will be made.
      Parameters:
      maxAge - a non-negative integer
      Returns:
      true if operation finished successfully, otherwise false
      Throws:
      IllegalArgumentException - if timeUnit is null or maxAge is less than zero
    • setUseRemoteConfig

      public void setUseRemoteConfig(boolean useRemoteConfig)
      Set to true if you want the SDK to download the configuration from dashboard and use it by default. Right now it only affects the LocationRequest. Default value is true from SDK version 2.83.5
      Parameters:
      useRemoteConfig -
    • isUseRemoteConfig

      public boolean isUseRemoteConfig()
    • useExternalLocations

      public void useExternalLocations(boolean useExternalLocaltions)
      Set to true if you want the SDK to use external locations instead of it's own indoor positioning system. This mode will only work in Building Mode. Default value is false.
      Parameters:
      useExternalLocaltions -
    • getUseExternalLocaltions

      public boolean getUseExternalLocaltions()
    • setLanguage

      @Deprecated public void setLanguage(String language)
      Deprecated.
      This method has been deprecated and has no functionality
      Set the language code you want the names of your cartography to be translated to. This will only apply if you have them configured in the dashboard. If there is no translation to the language you put here the default value will be the one the sdk will use.

      Defaults to empty so the SDK will not use any language preference.

      Parameters:
      language - The language code with just two characters, if there's more like for example en_US the three last characters will be ignored.
    • setLanguageFromSystem

      @Deprecated public void setLanguageFromSystem(android.content.Context context)
      Deprecated.
      This method has been deprecated and has no functionality
      Calls setLanguage(String) using the current phone language.
      Parameters:
      context - Current context.
      See Also:
    • getLanguage

      @Deprecated public String getLanguage()
      Deprecated.
      This method has been deprecated and has no functionality