Setup
Android
- Copy MedMDeviceKit.aar to your project libs directory.
- Add
implementation 'com.medm.devicekit:MedMDeviceKit:+@aar'
to dependencies section of your app’sbuild.gradle
.
dependencies {
...
implementation 'com.medm.devicekit:MedMDeviceKit:+@aar'
...
}
iOS
- Drag and drop the MedMDeviceKit.xcframework to your project navigator menu.
- Check ‘Copy if needed’ option.
- Select the target in the project settings editor.
- Select the 'Build Phases’ tab, and add MedMDeviceKit.xcframework to 'Embed Frameworks’ list.
Initialization
Use MedMDeviceKit.init
in order to initialize the SDK. Init must be called before any other method.
Use license provided to you by MedM. For Demo Edition any string is valid.
Prerequisites
Android
In order to use Bluetooth connectivity SDK requires following permissions:
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
on Android 10 or newer- Location services to be enabled on Android 6 or newer
The SDK notifies IErrorCallback.onPermissionsRequired()
in case any of these conditions aren’t met.
You can check Google documentation for the further explanation.
iOS
The SDK requires Bluetooth to be enabled. Otherwise ErrorCallback.onBluetoothTurnedOff()
will be called.
The system requests users’ permission on the first call to the API. The app has to provide text for this request.
To do that, add Privacy - Bluetooth Always Usage Description(NSBluetoothAlwaysUsageDescription)
to your properties list.
Usage
The main entry point of the library is MedMDeviceKit
class.
There are three main components: MedMScanner
, MedMDeviceManager
and MedMCollector
.
MedMScanner
is used for discovering new Bluetooth devices.MedMDeviceManager
is used for managing list of added devices.MedMCollector
is used for collecting data from added devices.
Background execution
If the application is expected to connect to Bluetooth devices in background some additional actions are required.
Android
The app must request ACCESS_BACKGROUND_LOCATION
permission and use a foreground service.
Depending on the target phone manufacturer it might be necessary to: request disabling battery optimizations, request wake lock, or ask a user to disable manufacturer-specific battery optimizations.
iOS
Add bluetooth-central
to Required background modes(UIBackgroundModes)
in your properties list.