Skip to main content

SDK Initialization

SDK initialization is a prerequisite for all features. This guide covers how to configure TSKitConfigOptions and complete SDK initialization.

When to Initialize

Initialize in AppDelegate's application:didFinishLaunchingWithOptions: method, before any other SDK calls.

Basic Initialization

#import <TopStepComKit/TopStepComKit.h>

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Create config (specify device platform and license)
TSKitConfigOptions *options = [TSKitConfigOptions configOptionWithSDKType:eTSSDKTypeFIT
license:@"YOUR_32_CHAR_LICENSE_KEY"];

// Initialize SDK
[[TopStepComKit sharedInstance] initSDKWithConfigOptions:options completion:^(BOOL isSuccess, NSError *error) {
if (isSuccess) {
TSLog(@"SDK initialized successfully");
} else {
TSLog(@"SDK initialization failed: %@", error.localizedDescription);
}
}];

return YES;
}

TSKitConfigOptions Parameters

Required Parameters

PropertyTypeDescription
sdkTypeTSSDKTypeDevice platform type — must match your actual hardware
licenseNSString *32-character license key provided by TopStep

SDK Types (TSSDKType)

Enum ValueDescription
eTSSDKTypeFITRealtek (FIT) series devices (default)
eTSSDKTypeFWBES (New Platform) series devices
eTSSDKTypeSJSJ (Shenju) series devices
eTSSDKTypeCRPCRP (Moyang) series devices
eTSSDKTypeUTEUTE series devices
eTSSDKTypeTPBTPB series devices

Optional Parameters

PropertyTypeDefaultDescription
isDevelopModelBOOLNOEnable verbose logging during development; disable in production
isSaveLogEnableBOOLNOWrite logs to the filesystem
logFilePathNSString *nilCustom log file path; nil uses the default path
logLevelTopStepLogLevelDebugMinimum log level (Debug / Info / Warning / Error)
isCheckBluetoothAuthorityBOOLNOCheck Bluetooth permission before operations; recommended for production
maxScanSearchDurationNSInteger15Maximum scan duration in seconds; 0 uses the default
maxConnectTimeoutNSInteger45Maximum connection timeout in seconds; 0 uses the default
maxTryConnectCountNSInteger10Maximum reconnection attempts after disconnection
autoConnectWhenAppLaunchBOOLNOAutomatically reconnect to the last device on app launch

Full Configuration Example

TSKitConfigOptions *options = [[TSKitConfigOptions alloc] init];
options.sdkType = eTSSDKTypeFIT;
options.license = @"abcd1234efgh5678ijkl9012mnop3456"; // 32 characters

// Logging (development)
options.isDevelopModel = YES;
options.isSaveLogEnable = YES;
options.logLevel = TopStepLogLevelDebug;

// Connection
options.isCheckBluetoothAuthority = YES;
options.maxScanSearchDuration = 30;
options.maxConnectTimeout = 60;
options.maxTryConnectCount = 5;
options.autoConnectWhenAppLaunch = YES;

[[TopStepComKit sharedInstance] initSDKWithConfigOptions:options completion:^(BOOL isSuccess, NSError *error) {
if (isSuccess) {
TSLog(@"SDK initialized — ready to scan for devices");
// Trigger auto-reconnect or navigate to main screen
} else {
TSLog(@"Initialization failed: %@", error.localizedDescription);
// Common causes: license is not 32 chars, or network validation failed
}
}];

Obtaining Feature Module Instances

After successful initialization, access feature modules directly as properties on [TopStepComKit sharedInstance]:

// BLE connection
id<TSBleConnectInterface> bleConnector = [TopStepComKit sharedInstance].bleConnector;

// Device find
id<TSPeripheralFindInterface> peripheralFind = [TopStepComKit sharedInstance].peripheralFind;

// Heart rate
id<TSHeartRateInterface> heartRate = [TopStepComKit sharedInstance].heartRate;

// Data sync
id<TSDataSyncInterface> dataSync = [TopStepComKit sharedInstance].dataSync;

// Blood oxygen
id<TSBloodOxygenInterface> bloodOxygen = [TopStepComKit sharedInstance].bloodOxygen;

// Blood pressure
id<TSBloodPressureInterface> bloodPressure = [TopStepComKit sharedInstance].bloodPressure;

// Sleep
id<TSSleepInterface> sleep = [TopStepComKit sharedInstance].sleep;

// Watch face
id<TSPeripheralDialInterface> dial = [TopStepComKit sharedInstance].dial;

All available module properties are listed in TopStepComKit.h.

Recommended Practice

[TopStepComKit sharedInstance] is already a singleton — call it directly anywhere without storing extra references.

Important Notes

  1. initSDKWithConfigOptions:completion: must be called on the main thread
  2. license must be exactly 32 alphanumeric characters
  3. The completion callback is executed on the main thread
  4. Set isDevelopModel to NO in production to avoid performance overhead
  5. If you support multiple device platforms, initialize the SDK instance for each platform separately