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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowInvalidSSLCertificate(boolean allowInvalidSSLCertificate)Tell the system to trust the SSL certificate of the server (even though the Authority is not valid).StringcurrentEmailAccount()Return user email of credentials previously provided withsetApiKey(String, String),setUserPass(String, String)or declared in the Android ManifestlonggetCacheMaxAge()Get the maximum age of a cached response.StringgetDashboardURL()Obtains the currently Dashboard url usedbooleanisAllowInvalidSSLCertificate()Returns true if all SSL certificates are trustedbooleanisUseRemoteConfig()booleansetApiKey(String email, String apiKey)Provides your API key to the Situm SDK for Android.booleansetCacheMaxAge(long maxAge, TimeUnit timeUnit)Sets the maximum age of a cached response.voidsetDashboardURL(String url)Set the Dashboard URL used by the SDKvoidsetUseRemoteConfig(boolean useRemoteConfig)Set to true if you want the SDK to download the configuration from dashboard and use it by default.booleansetUserPass(String email, String password)Provides user's email and password.
-
-
-
Method Detail
-
setApiKey
public boolean setApiKey(@NonNull String email, @NonNull String apiKey)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.- Parameters:
email- email that identifies the account. Can't be empty.apiKey- key obtained at situm.es. Can't be empty- Returns:
- true if operation finished successfully, otherwise false
- Throws:
IllegalArgumentException- if email or apiKey are null or empty
-
currentEmailAccount
@Nullable public String currentEmailAccount()
Return user email of credentials previously provided withsetApiKey(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(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 false but it may change in the future- Parameters:
useRemoteConfig-
-
isUseRemoteConfig
public boolean isUseRemoteConfig()
-
-