Classes
The following classes are available globally.
-
Read only data set for 3D axis data
See moreDeclaration
Swift
open class BKAxisData : NSObject, NSSecureCoding
-
Read only data object for sensor data that is emitted by blukii beacons
BeaconSensor values are part of
BKDiscoveryData
Seealso
BKDiscoveryData
Declaration
Swift
open class BKBeaconSensorData : NSObject, NSSecureCoding
-
Main Controller class for discovering BLE modules
BlukiiClient is a single point of contact for all data retieving actions as follows:
- Discovering BLE modules, extracting BLE advertised data
- Decryption of blukii SecureBeacon advertising
A. Discover BLE modules and extract their BLE data
To do this you have to do the following steps:
1. Initialize and start discovery
Call
initDiscovery()
and implement theBKClientDiscoveryDelegate
delegates. After initialization is ready (BKClientDiscoveryDelegate.onDiscoveryInitialized()
) you can start the discovery.var mBlukiiClient: BKClient! override func viewDidLoad() { ... mBlukiiClient = BKController.instance.getDiscoveryClient() mBlukiiClient.discoveryDelegate = self mBlukiiClient.initDiscovery() ... } func stopDiscovery() { mBlukiiClient.stopDiscovery() } // Discovery Delegate func onDiscoveryInitialized() { if mBlukiiClient.startDiscovery() { // Discovery successfully started } } func onDiscoveryResult(discoveryResultList: [BKDiscoveryData]) { // retrieve BLE results } func onDiscoveryError(errorCode: BKDiscoveryError) { // retrieve errors } func onDiscoveryInfo(infoCode: BKDiscoveryInfo) { // retrieve infos and changed states }
2. Configure discovery settings
Use the
BKDiscoverySettings
object for configuring discovery. GetBKClient.discoverySettings
to retrieve the settings property set.func onInitialized() { // Discovery successfully initialized let discoverySettings: BKDiscoverySettings = mBlukiiClient.discoverySettings discoverySettings.setRssiThreshold(-100) discoverySettings.scanDuration = 10000 ... if mBlukiiClient.startDiscovery() { // Discovery successfully started } }
When BLE scanner is started the BLE discovery is acting according to the
BKDiscoverySettings
:- The scanner is searching for BLE modules inside the defined rssi range (
BKDiscoverySettings.getRssiThreshold()
). - After one scan duration (
BKDiscoverySettings.scanDuration
) the results are called back to (BKClientDiscoveryDelegate.onDiscoveryResult(_:)
) - This is repeated until BLE Scanning is stopped by
BKClient.stopDiscovery()
or the app did enter the background. - if the scanner is paused according to the
BKDiscoverySettings
the infoBKDiscoveryInfo.bleScanPaused
is called. - For background scanning it is necessary to be in the Configured iBeacon Region. Background scanning will only Scan, if the device is in the configured iBeacon Region and the display will be switched on. In background it is possible to scan for iBeacon, EddystoneBeacon and InfoBeacon.
3. Retrieve results
The callback
BKClientDiscoveryDelegate.onDiscoveryResult(_:)
will be called after finishing every discovery phase. It retrieves the discovered list of BKOutputElements.Note: If no BLE modules have been found discoveryResultList is empty (not nil).
func onDiscoveryResult(discoveryResultList: [BKDiscoveryData]) { // Discovery phase has finished: list of OutputElements are retrieved for discoveryData in discoveryResultList { let id = discoveryData.blukiiId let rssi = discoveryData.getRssi() ... } }
4. Retrieve errors and infos
The callbacks
BKClientDiscoveryDelegate.onDiscoveryError(_:)
andBKClientDiscoveryDelegate.onDiscoveryInfo(_:)
will be called if there is important information about the discover process.func onDiscoveryError(errorCode: BKDiscoveryError) { // An error has been sent from discover } func onDiscoveryInfo(infoCode: BKDiscoveryInfo) { // An info has been sent from discovery }
5. Permission
In Info.plist set the following keys for Beacon Detection:
- NSLocationAlwaysUsageDescription
- NSBluetoothAlwaysUsageDescription
Add the Follow Capapilities to your Project, for scanning Beacons in Background:
- Background Mode: Location Updates
- Background Mode: Uses Bluetooth LE accessoires
B. Decryption of SecureBeacon advertising
blukii SecureBeacons are encrypted to prevent third parties from misusing the Beacon identification.
The encryption is affecting the mac address and the iBeacon Major and Minor value.
You can decrypt DiscoveryData by calling
decryptSecureBeacons(discoveryDataList:)
. To detect a SecureBeacon, you have to set your secureBeacon UUID toBKDiscoverySettings.securebeaconUUID
The delegate
BKDecryptSecureBeaconsDelegate.onDecryptSecureBeacons(_:decryptedCount:)
is retrieving a copy of the input parameter list containing decrypted values. Each BKDiscoveryData object, that has been decrypted is marked withBKDiscoveryData.secureBeaconState
asBKSecureBeaconState.decrypted
.func onDecryptSecureBeacons(_ decryptedDiscoveryDataList: [BKDiscoveryData], decryptedCount: Int) { print("BlukiiClient.onDiscoveryResult: DecryptSecureBeacons Successful: Count=" + decryptedCount) } func onDecryptError(_ error: Error) { print("BlukiiClient.onDiscoveryResult: DecryptSecureBeacons failed: error=" + error.localizedDescription) }
Note: SecureBeacons can only be decrypted by its owner, so the corresponding user needs to be logged in (@see
See moreBKBlukiiCloud
)Declaration
Swift
open class BKClient : NSObject, BKDeviceDiscoveryServiceDelegate, BKDiscoveryBackendResolverDelegate
-
Read only data object for emitted data of on BLE module.
BKDiscoveryData
is a collection of BLE data that is scanned during one scan duration for one BLE module.It contains the following values if it is provided by the module’s hardware and firmware
- Device found date
- RSSI value
- blukii Hardware specific advertising data like firmware, blukii type, advertising interval, battery and txPower
- Sensor data results of blukii sensor beacons. See
BKBeaconSensorData
- Key data of blukii SmartKeys. See
BKKeyData
- Eddystone protocol data values. See
BKEddystoneData
- iBeacon protocol data values. See
BKiBeaconData
Note: If the scan scan duration (see
BKDiscoverySettings.scanDuration
) is longer than the advertising interval of the module than each value is read only once. The following data frames of the same type are ignored if the corresponding fields are already set in theBKDiscoveryData
object. The discovery date (deviceFoundDate
) is the timestamp of the last BLE frame that is scanned by the mobile device.
See moreBKDiscoveryData
is returned by teh delegate functionBKClientDiscoveryDelegate.onDiscoveryResult(_:)
Declaration
Swift
open class BKDiscoveryData : NSObject, NSSecureCoding
-
Property set of settings to configure the discovering process.
The DiscoverySettings properties are affecting the discovery process that is started by
BKClient.initDiscovery()
and theBKDiscoveryData
contents of the result delegate.You can access the DiscoverySettings by
BKClient.discoverySettings
Every setting value is writeable and has a default value that is used if not changed by the developer.
See moreDeclaration
Swift
open class BKDiscoverySettings : NSObject
-
Read only data object for Eddystone data that is emitted by beacons
See Eddystone specification at https://github.com/google/eddystone/blob/master/protocol-specification.md
BKEddystoneData
can contain data of unencrypted EddyStone UID, URL and TLM.
See moreBKEddystoneData
values are part ofBKDiscoveryData
.Declaration
Swift
open class BKEddystoneData : NSObject, NSSecureCoding
-
Read only data set for blukii SmartKey
See moreDeclaration
Swift
open class BKKeyData : NSObject, NSSecureCoding
-
Read only data object for iBeacon data that is emitted by beacons
See iBeacon specification at https://developer.apple.com/ibeacon
iBeaconData values are part of
See moreBKDiscoveryData
Declaration
Swift
open class BKiBeaconData : NSObject, NSSecureCoding
-
This class is the main controller for blukii cloud based actions.
You can get a
BKBlukiiCloud
object viaBKController.instance
.With a blukii cloud object you have access to the cloud state. You can set credentials and a API key, get the user role, check if the user is authenticated and you can do the login and logout.
Note: The API key has be purchased from blukii. Please contact support@blukii.com for more information.
See moreDeclaration
Swift
open class BKBlukiiCloud
-
Main controller of blukii SDK
BlukiiController controls the instantiation of all controllers that can only be loaded by BlukiiController.
Please note: There must be only one BlukiiController instance to prevent multiple instantiations of package controllers and data structures.
Example Snippet
See moreoverride func viewDidLoad() { ... mBlukiiCloud = BKController.instance.getCloud() ... }
Declaration
Swift
open class BKController
-
Helper class to validate application and mobile device features
See moreDeclaration
Swift
open class BKFeatureValidator : NSObject
-
Main controller class of package info, for interacting with blukii Manager Info CMS (@see https://manager.blukii.com)
BlukiiClient class contains discovery functions as follows:
- Request for getting blukii Info output data.
- Reporting of blukii Info clicks.
- Reporting of blukii Info violations.
Note: These functions needs to set an developers API key by
See moreBKBlukiiCloud.setApiKey(apiKey:)
. Settings of credentials and user login is not needed for BlukiiInfo functions.Declaration
Swift
open class BKBlukiiInfo : NSObject
-
Read only data object for Info Bundle data retrieved from blukii Manager Info CMS.
It contains the results of the
See moreBKBlukiiInfo.getInfoBundles(bundleIds:completionHandler:)
request to the blukii Manager Info CMS (https://manager.blukii.com).Declaration
Swift
open class BKInfoBundleData : NSObject, NSCoding
-
Read only data object for output language based info bundle data retrieved from blukii Manager Info CMS.
It is a child object of
See moreBKInfoBundleData
and contains all data that is language specificDeclaration
Swift
open class BKInfoBundleOutputData : NSObject, NSCoding
-
Read only data object for data of BLE discover and resolving process.
It contains the results of the
BKBlukiiInfo.getInfoData(blukiiIds:completionHandler:)
request to the blukii Manager Info CMS(https://manager.blukii.com).The BKInfoData fields contain the values of one corresponding blukii number.
See moreDeclaration
Swift
open class BKInfoData : NSObject, NSSecureCoding
-
Read only data object for output language based blukii data retrieved from blukii Manager Info CMS.
It is a child object of
See moreBKInfoData
and contains all data that is language specificDeclaration
Swift
open class BKInfoOutputData : NSObject, NSCoding