API Reference
Complete API reference for the MOSA Mobile SDK across all platforms.
Overview
This section provides comprehensive API documentation for all SDK methods, models, and enums. APIs are organized by functional domain and include multi-platform code examples. All APIs are designed to be consistent across Android, iOS, and Flutter platforms.
Table of Contents
- Initialization
- Unlock Key Management
- Dock Operations
- Area Management
- Session Management
- Device Capabilities
- Permission Management
- Sync Operations
- Evidence Management
- Event Streams
- Data Models
- Enums
Initialization
Initialize the SDK with API key and user ID. See Getting Started for detailed initialization instructions.
- Android
- iOS
- Flutter
val sdk = MOSADockSDK.builder()
.setActivity(this)
.setApiKey("your-api-key")
.setUserId("user-123")
.setAutoRequestPermissions(true)
.build()
MosaDockSDK.initialize(
apiKey: "your-api-key",
userId: "user-123"
)
let sdk = MosaDockSDK.shared
await mosaDockSdk.initialize(
apiKey: 'your-api-key',
userId: 'user-123',
);
Unlock Key Management
The SDK provides unlock key management for authenticating and authorizing dock operations. Unlock keys are temporary cryptographic keys requested from the backend with a limited validity period (typically 15 minutes).
requestUnlockKey
Request an unlock key for dock operations. The SDK provides different unlock key types for various dock operations. Each type has specific required arguments.
Parameters:
type(UnlockKeyType) - Type of unlock key (bikeLock, bikeUnlock, rentBikeUnlock, rentBikeLock, testLock)areaId(String, optional) - Area ID (required for bikeLock, rentBikeUnlock, rentBikeLock, testLock)
Returns: UnlockKey object or null if request fails
Unlock Key Types
bikeLock
Use Case: Lock a bike at a parking area
Required Arguments: areaId (String) - ID of the parking area
- Android
- iOS
- Flutter
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.BikeLock,
areaId = "area-123"
)
let unlockKey = try await sdk.requestUnlockKey(
type: .bikeLock,
areaId: "area-123"
)
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.bikeLock,
areaId: 'area-123',
);
bikeUnlock
Use Case: Unlock a bike from a parking dock
Required Arguments: None
- Android
- iOS
- Flutter
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.BikeUnlock
)
let unlockKey = try await sdk.requestUnlockKey(
type: .bikeUnlock
)
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.bikeUnlock
);
rentBikeUnlock
Use Case: Rent/unlock a bike from a sharing area
Required Arguments: areaId (String) - ID of the sharing area
- Android
- iOS
- Flutter
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.RentBikeUnlock,
areaId = "area-123"
)
let unlockKey = try await sdk.requestUnlockKey(
type: .rentBikeUnlock,
areaId: "area-123"
)
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.rentBikeUnlock,
areaId: 'area-123',
);
rentBikeLock
Use Case: Return/lock a bike at a sharing area
Required Arguments: areaId (String) - ID of the sharing area
- Android
- iOS
- Flutter
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.RentBikeLock,
areaId = "area-123"
)
let unlockKey = try await sdk.requestUnlockKey(
type: .rentBikeLock,
areaId: "area-123"
)
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.rentBikeLock,
areaId: 'area-123',
);
testLock
Use Case: Perform a test unlock. The dock won't go into the in-use state and remains ready for use again after attaching the chain back.
Required Arguments: areaId (String) - ID of the test area
- Android
- iOS
- Flutter
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.TestLock,
areaId = "area-123"
)
let unlockKey = try await sdk.requestUnlockKey(
type: .testLock,
areaId: "area-123"
)
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.testLock,
areaId: 'area-123',
);
getLastStoredUnlockKey
Retrieve the last stored unlock key from local cache.
- Android
- iOS
- Flutter
val lastKey = sdk.getLastStoredUnlockKey()
let lastKey = await sdk.getLastStoredUnlockKey()
final lastKey = await mosaDockSdk.getLastStoredUnlockKey();
Returns: UnlockKey object or null if no key is stored
Dock Operations
unlockSmartLock / handleClientUnlock
Execute dock unlock/lock operation. This method handles the complete flow: NFC scanning, BLE connection, key transmission, and dock state changes.
- Android
- iOS
- Flutter
sdk.unlockSmartLock(
unlockKey = unlockKey,
gfaLocationType = MOSADockLocationType.PARKING,
callback = callback
)
try await sdk.unlockSmartLock(
with: unlockKey,
location: .parking,
delegate: delegate
)
await mosaDockSdk.handleClientUnlock(
unlockKey: unlockKey,
locationType: MosaDockLocationType.parking.value,
);
Parameters:
unlockKey(UnlockKey) - The unlock key obtained fromrequestUnlockKey()locationType(LocationType) - Location type:parkingorsharing
Callbacks: See SDK Callbacks for complete callback documentation
Area Management
getAreas
Search and retrieve areas with optional filters.
- Android
- iOS
- Flutter
val areas = sdk.getAreas(
status = "active",
areaType = "parking",
query = "downtown",
page = 1,
limit = 20
)
let areas = try await sdk.getAreas(
status: "active",
areaType: "parking",
query: "downtown",
page: 1,
limit: 20
)
final areas = await mosaDockSdk.getAreas(
status: 'active',
areaType: 'parking',
query: 'downtown',
page: 1,
limit: 20,
);
Parameters:
status(String, optional) - Filter by area statusareaType(String, optional) - Filter by area type (parking/sharing)query(String, optional) - Search querypage(Int, default: 1) - Page numberlimit(Int, default: 20) - Results per pagesortBy(String, default: "name") - Sort fieldsortOrder(String, default: "asc") - Sort order (asc/desc)
Returns: AreaSearchResponse containing list of areas and pagination info
getAreasForMap
Retrieve areas within a geographic radius for map display.
- Android
- iOS
- Flutter
val areas = sdk.getAreasForMap(
areaType = "parking",
latitude = 37.7749,
longitude = -122.4194,
radius = 1000.0,
limit = 100
)
let areas = try await sdk.getAreasForMap(
areaType: "parking",
latitude: 37.7749,
longitude: -122.4194,
radius: 1000.0,
limit: 100
)
final areas = await mosaDockSdk.getAreasForMap(
areaType: 'parking',
latitude: 37.7749,
longitude: -122.4194,
radius: 1000.0,
limit: 100,
);
Parameters:
areaType(String, optional) - Filter by area typestatus(String, optional) - Filter by area statuslatitude(Double) - Center latitudelongitude(Double) - Center longituderadius(Double, optional) - Search radius in meterslimit(Int, default: 100) - Maximum results
Returns: AreaSearchResponse containing list of areas
Session Management
getCurrentSession
Retrieve the current active session, if any.
- Android
- iOS
- Flutter
val currentSession = sdk.getCurrentSession()
let currentSession = await sdk.getCurrentSession()
final currentSession = await mosaDockSdk.getLastSession();
Returns: Session object or null if no active session
getSessionHistory
Retrieve paginated session history for the current user.
- Android
- iOS
- Flutter
val history = sdk.getSessionHistory(
page = 1,
limit = 20
)
let history = try await sdk.getSessionHistory(
page: 1,
limit: 20
)
final history = await mosaDockSdk.getSessionHistory(
page: 1,
limit: 20,
);
Parameters:
page(Int, default: 1) - Page numberlimit(Int, default: 20) - Results per page
Returns: SessionHistoryResponse containing list of sessions and pagination info
getSessionStatistics
Retrieve session statistics for the current user.
- Android
- iOS
- Flutter
val stats = sdk.getSessionStatistics()
let stats = try await sdk.getSessionStatistics()
final stats = await mosaDockSdk.getSessionStatistics();
Returns: SessionStatistics object with aggregated session data
Device Capabilities
isBLESupported
Check if the device supports Bluetooth Low Energy.
- Android
- iOS
- Flutter
val supported = sdk.isBLESupported()
let supported = sdk.isBLESupported
final supported = await mosaDockSdk.isBleSupported();
Returns: Boolean indicating BLE support
isNFCSupported
Check if the device supports NFC.
- Android
- iOS
- Flutter
val supported = sdk.isNFCSupported()
let supported = sdk.isNFCSupported
final supported = await mosaDockSdk.isNfcSupported();
Returns: Boolean indicating NFC support
isBLEEnabled
Check if Bluetooth is currently enabled on the device.
- Android
- iOS
- Flutter
val enabled = sdk.isBLEEnabled()
let enabled = sdk.isBLEEnabled
final enabled = await mosaDockSdk.isBleEnabled();
Returns: Boolean indicating if BLE is enabled
isNFCEnabled
Check if NFC is currently enabled on the device.
- Android
- iOS
- Flutter
val enabled = sdk.isNFCEnabled()
let enabled = sdk.isNFCEnabled
final enabled = await mosaDockSdk.isNfcEnabled();
Returns: Boolean indicating if NFC is enabled
Permission Management
checkAndRequestPermissions
Check and request all required permissions for SDK operations.
- Android
- iOS
- Flutter
val granted = sdk.checkAndRequestPermissions()
let granted = await sdk.checkAndRequestPermissions()
final granted = await mosaDockSdk.checkAndRequestPermissions();
Returns: Boolean indicating if all permissions were granted
hasRequiredPermissions
Check if all required permissions are currently granted.
- Android
- iOS
- Flutter
val hasPermissions = sdk.hasRequiredPermissions()
let hasPermissions = sdk.hasRequiredPermissions
final hasPermissions = await mosaDockSdk.hasRequiredPermissions();
Returns: Boolean indicating if all required permissions are granted
getMissingPermissions
Get a list of missing required permissions.
- Android
- iOS
- Flutter
val missing = sdk.getMissingPermissions()
let missing = sdk.getMissingPermissions
final missing = await mosaDockSdk.getMissingPermissions();
Returns: List of permission names that are missing
Sync Operations
forceSyncNow
Manually trigger synchronization of pending events to the backend.
- Android
- iOS
- Flutter
sdk.forceSyncNow()
await sdk.forceSyncNow()
await mosaDockSdk.forceSyncNow();
getPendingEventsCount
Get the number of events pending synchronization.
- Android
- iOS
- Flutter
val count = sdk.getPendingEventsCount()
let count = await sdk.getPendingEventsCount()
final count = await mosaDockSdk.getPendingEventsCount();
Returns: Integer count of pending events
See Also: Offline and Sync for detailed sync documentation
Evidence Management
storeEvidencePhoto
Store an evidence photo for a session.
- Android
- iOS
- Flutter
val photoId = sdk.photoOperations().storeEvidencePhoto(
sessionId = "session-123",
photoPath = "/path/to/photo.jpg"
)
let photoId = try await sdk.storeEvidencePhoto(
sessionId: "session-123",
photoPath: "/path/to/photo.jpg"
)
final photoId = await mosaDockSdk.storeEvidencePhoto(
sessionId: 'session-123',
photoPath: '/path/to/photo.jpg',
);
Parameters:
sessionId(String) - Session ID to associate the photo withphotoPath(String) - Local file path to the photo
Returns: String photo ID
getEvidencePhotos
Retrieve evidence photos for a session.
- Android
- iOS
- Flutter
val photos = sdk.photoOperations().getEvidencePhotos("session-123")
let photos = try await sdk.getEvidencePhotos(sessionId: "session-123")
final photos = await mosaDockSdk.getEvidencePhotos('session-123');
Parameters:
sessionId(String) - Session ID
Returns: List of evidence photo objects
getEvidencePhotoURL
Get the URL for an evidence photo.
- Android
- iOS
- Flutter
val url = sdk.photoOperations().getEvidencePhotoURL("photo-123")
let url = try await sdk.getEvidencePhotoURL(photoId: "photo-123")
final url = await mosaDockSdk.getEvidencePhotoURL('photo-123');
Parameters:
photoId(String) - Photo ID
Returns: String URL to the photo
Event Streams
The SDK provides reactive event streams for real-time updates. Subscribe to these streams to receive callbacks and state changes.
dockCallbackEvents
Stream of dock operation callbacks (NFC scan, BLE connection, dock state changes, etc.).
- Android
- iOS
- Flutter
// Android uses callback interface, not streams
sdk.unlockSmartLock(
unlockKey = unlockKey,
gfaLocationType = MOSADockLocationType.PARKING,
callback = object : MOSADockSDKCallback {
override fun onNFCScanCompleted(mosaTag: MosaTag) { }
override fun onBleConnected() { }
// ... other callbacks
}
)
// iOS uses delegate protocol, not streams
sdk.setDelegate(self)
// Implement MosaDockDelegate methods
mosaDockSdk.dockCallbackEvents.listen((event) {
switch (event.type) {
case DockCallbackEventType.nfcScanCompleted:
// Handle NFC scan
break;
case DockCallbackEventType.bleConnected:
// Handle BLE connection
break;
// ... other events
}
});
See Also: SDK Callbacks for complete callback documentation
syncStateEvents
Stream of sync state changes (syncing, idle, error).
- Android
- iOS
- Flutter
sdk.isSyncingStateFlow().collect { syncing ->
// Handle sync state
}
sdk.syncStatePublisher
.sink { state in
// Handle sync state
}
mosaDockSdk.syncStateEvents.listen((event) {
// Handle sync state
});
bleConnectionStateEvents
Stream of BLE connection state changes.
- Android
- iOS
- Flutter
sdk.getBleConnectionStateFlow().collect { connected ->
// Handle connection state
}
sdk.bleConnectionPublisher
.sink { connected in
// Handle connection state
}
mosaDockSdk.bleConnectionStateEvents.listen((event) {
// Handle connection state
});
sdkLogs
Stream of SDK log messages for debugging.
- Android
- iOS
- Flutter
// Enable advanced logging during initialization
val sdk = MOSADockSDK.builder()
.setAdvancedLogging(true)
.build()
// Enable logging during initialization
MosaDockSDK.initialize(
apiKey: "key",
userId: "user",
enableLogging: true
)
mosaDockSdk.sdkLogs.listen((log) {
print('SDK Log: ${log.message}');
});
Data Models
UnlockKey
The UnlockKey represents a temporary cryptographic key used to authenticate and authorize dock operations. Keys are requested from the backend and have a limited validity period (typically 15 minutes).
Properties:
keyId(String, non-null) - Unique identifier for the keysessionId(String, non-null) - Associated session IDtoken(Array of integers, non-null) - The actual unlock tokenexpiryTime(Integer, non-null) - Expiry time as Unix timestamp (seconds)keyType(UnlockKeyType, non-null) - Type of unlock key (enum)userId(String, nullable) - User IDassetId(String, nullable) - Asset IDareaId(String, nullable) - Area ID
Usage Example:
- Android
- iOS
- Flutter
lifecycleScope.launch {
// Request key
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.BikeLock,
areaId = "area-123"
)
if (unlockKey != null && !unlockKey.isExpired) {
// Use key for dock operation
sdk.unlockSmartLock(
unlockKey = unlockKey,
gfaLocationType = MOSADockLocationType.PARKING,
callback = this@MainActivity
)
} else {
// Handle expired or null key
showError("Key expired or request failed")
}
}
Task {
do {
// Request key
let unlockKey = try await sdk.requestUnlockKey(
type: .bikeLock,
areaId: "area-123"
)
// Check expiry
let currentTime = Int(Date().timeIntervalSince1970)
if unlockKey.expiryTime > currentTime {
// Use key for dock operation
try await sdk.unlockSmartLock(
with: unlockKey,
location: .parking,
delegate: self
)
} else {
// Handle expired key
showError("Key expired")
}
} catch {
// Handle error
showError("Failed: \(error)")
}
}
try {
// Request key
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.bikeLock,
areaId: 'area-123',
);
// Check expiry
if (unlockKey.isValid) {
// Use key for dock operation
await mosaDockSdk.handleClientUnlock(
unlockKey: unlockKey,
locationType: MosaDockLocationType.parking.value,
);
} else {
// Handle expired key
showError('Key expired');
}
} catch (e) {
// Handle error
showError('Failed: $e');
}
Session
Represents a single bike/dock usage period. Sessions are automatically created and managed by the SDK.
Properties:
id(String) - Unique session identifieruserId(String) - User ID associated with the sessionareaId(String, nullable) - Area ID where the session takes placedockId(String, nullable) - Dock ID where the session takes placefactoryDockId(String, nullable) - Factory dock ID (hardware identifier)bikeId(String, nullable) - Bike ID associated with the sessionstatus(SessionStatus) - Current session statusstartTime(DateTime, nullable) - Session start timeendTime(DateTime, nullable) - Session end timecreatedAt(DateTime) - Session creation timeupdatedAt(DateTime) - Session last update timeusageTime(Double, nullable) - Usage time in secondsareaName(String, nullable) - Area name (populated from area data)areaType(AreaType, nullable) - Area type (populated from area data)areaFormattedAddress(String, nullable) - Area formatted addressareaLocationPin(GeoJSONPoint, nullable) - Area location pinareaGeoFencePath(GeoJSONPolygon, nullable) - Area geofence pathareaShadowPolygon(GeoJSONPolygon, nullable) - Area shadow polygonevidenceImageId(String, nullable) - Evidence image IDevidenceImageUrl(String, nullable) - Evidence image URLmetadata(String, nullable) - Additional metadata as JSON string
Area
Represents a parking or sharing area.
Properties:
id(String) - Unique area identifiername(String) - Area nametype(AreaType) - Area type (parking or sharing)status(String) - Area statusformattedAddress(String, nullable) - Formatted addresslocationPin(GeoJSONPoint, nullable) - Location coordinatesgeoFencePath(GeoJSONPolygon, nullable) - Geofence boundaryshadowPolygon(GeoJSONPolygon, nullable) - Map display polygonimages(List<String>, nullable) - Image URLslevel(AreaLevel, nullable) - Area level (overground or underground)
MosaTag
Represents NFC tag data read from a dock during scanning.
Properties:
macAddress(String) - Dock MAC addresstagData(String) - Raw tag datadockId(String, nullable) - Dock ID if available
Enums
UnlockKeyType
Defines the purpose of an unlock key. The UnlockKeyType enum defines the purpose of an unlock key.
Values:
bikeLock- Lock a bike at a parking areabikeUnlock- Unlock a bike from a parking dockrentBikeUnlock- Rent/unlock a bike from a sharing arearentBikeLock- Return/lock a bike at a sharing areatestLock- Perform a test unlock. The dock won't go into the in-use state and remains ready for use again after attaching the chain back.
LocationType
Defines the location context for dock operations.
Values:
parking- Parking area contextsharing- Sharing area context
SessionStatus
Defines the current state of a session.
Values:
created- Session created but not yet activeactive- Session is currently activecompleted- Session completed successfullyfailed- Session failedcancelled- Session was cancelled
AreaType
Defines the type of area.
Values:
parking- Parking areasharing- Sharing area
AreaLevel
Defines the level of an area.
Values:
overground- Above ground levelunderground- Below ground level
Related Documentation
- SDK Callbacks - Complete callback documentation
- Getting Started - Installation and first integration
- Use Case Guides - Complete examples
- Offline and Sync - Offline functionality and sync patterns