For a detailed documentation of all SDK function please see the Api Documentation
Here you can find information about how to upgrade to a new SDK version.
You can find a sample App implementation of the SDK in Kotlin. If you have to use Java you can find a minimalistic sample App Java.
For the sample App you need to provide a baseUrl
, a clientId
and a Set of (SSL) certificate
’s. All informations can be found here
Grab the latest SDK via Gradle:
implementation 'com.sensorberg.smartspaces:sdk:VERSION'
to let Gradle download the SDK from our servers. You can find the latest VERSION
on our Maven Repository.
You also need to create a global gradle.properties
file in USER_HOME/.gradle/
MAVEN_USERNAME=<username>
MAVEN_PASSWORD=<password>
replace <username>
and <password>
with the credentials provided by us.
To setup the maven repository in your app you have to open the build.gradle
file of your app module (not the root) and add the following snippet:
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.tapkey.com" }
maven {
url "https://maven.sensorberg.io/artifactory/smartspaces/"
credentials {
username = MAVEN_USERNAME
password = MAVEN_PASSWORD
}
}
}
Because of the changes and improvements of the Bluetooth API and BLE with Android 5.0 the Android minSdkVersion
for our SDK is 21. So your project needs to set the minSdkVersion
also to 21 or higher.
You need also to add packagingOptions
to the app build.gradle
.
packagingOptions {
exclude 'META-INF/lib_release.kotlin_module'
exclude 'META-INF/library_release.kotlin_module'
}
Use the SmartSpacesSdk.Builder to initialize the SDK.
val certificates: Set<String> = ...
SmartSpacesSdk.Builder(application, baseUrl, clientId, certificates)
.build()
You need to provide the baseUrl
of the server, the clientId
to authenticate the app at the server and the (SSL) certificate of the server. All this information will be provided by us.
Our SDK is Kotlin and Coroutines first. So the main API will offer suspend
functions or return Flow
. We also provide support functions that uses Callback API or LiveData in case you can not use Coroutines (or even Kotlin).
Following permissions will be merged to your projects AndroidManifest.xml
automagicaly by Gradle
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
The only thing you have to do is to ask the user for location permission to use the SDK.
We are using Timber for logging in our SDK (See Timber GitHub). If you want to see the logging of the SDK use Timber and add an Timber.Tree
to enable logging.
Timber.plant(object : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
Log.d("DEBUG", message)
}
})
SmartSpacesSdk is the main entry point to access all the functions. From there one can access the other interfaces. The SDK must be a singleton in the application. The SDK have the following main interfaces.
Manages user authentication.
Provides methods for login, logout, change password, get user and get logged status.
To acquire the single instance of the user manager call sdk.getUserManager()
Via the Unit Controller the app can access available and nearby units, filter by type and command them to open.
To acquire the single instance of the Unit Controller call sdk.getUnitController()
With the booking manager you are able to create bookings of a room or a locker, delete bookings which are not started yet or end currently ongoing bookings.
To acquire the single instance of the Unit Controller call sdk.getBookingManager()
Controller for magneto and NFC “tap” actions.
To acquire the single instance of the tap controller call sdk.getTapController()
Controller for IotDevice(s).
To acquire an instance of the IotDeviceController call sdk.getIotDeviceController()
.
There’s also a refresh()
method that will re-query backend for latest information regarding user, units, schedules, etc.
Existing LiveData<Response>
will change to executing
(with the old values still available in .data
field) and it will get updated once the API calls succeeded.
You should call refresh when your App is going to foreground. By default User
, IotUnits
and MyBookings
are refreshed. See enum values.