Samples and Tutorials
This section provides links to sample applications and end-to-end tutorials for integrating the MOSA SDK.
Sample Applications
Android
- Example App: MOSA-dock-lib-android-example (contact MOSA for repository access)
- Features: Complete Android integration example with Compose UI
- Includes: Area list, session management, dock operations, sync status
iOS
- Example App: MosaSdkExample (contact MOSA for repository access)
- Features: Complete iOS integration example with SwiftUI
- Includes: Area list, session management, dock operations, sync status
Flutter
- Example App: mosa_dock_sdk_flutter/example (contact MOSA for repository access)
- Features: Complete Flutter integration example
- Includes: Cross-platform dock operations, callback handling, sync status
End-to-End Tutorials
Tutorial 1: First Dock Connection
Goal: Connect to your first MOSA dock and perform a test unlock operation.
Steps:
- Install SDK - Add SDK to your project
- Request Test Key - Request a
testLockkey - Handle Callbacks - Implement callback handlers
Expected Result: Successfully connect to dock and receive callbacks.
Tutorial 2: Bike Parking Flow
Goal: Implement complete bike parking functionality.
Steps:
- Follow Bike Parking Guide - Complete guide
- Lock Operation: Implement bike locking
- Unlock Operation: Implement bike unlocking
- Error Handling: Add comprehensive error handling
- UI Updates: Update UI based on callbacks
Expected Result: Full bike parking functionality working.
Tutorial 3: Bike Sharing Flow
Goal: Implement complete bike sharing functionality.
Steps:
- Follow Bike Sharing Guide - Complete guide
- Rent Operation: Implement bike rental
- Return Operation: Implement bike return
- Rental Timer: Track rental duration
- Session Management: Handle session lifecycle
Expected Result: Full bike sharing functionality working.
Use Case Examples
Example 1: Simple Unlock
Minimal example showing basic unlock operation:
- Android
- iOS
- Flutter
val sdk = MOSADockSDK.builder()
.setActivity(this)
.setApiKey("your-api-key")
.setUserId("user-123")
.build()
lifecycleScope.launch {
val unlockKey = sdk.requestUnlockKey(
type = MOSADockUnlockKeyType.BikeUnlock,
areaId = "area-123"
)
unlockKey?.let {
sdk.unlockSmartLock(
unlockKey = it,
gfaLocationType = MOSADockLocationType.PARKING,
callback = object : MOSADockSDKCallback {
override fun onDockUnlocked() {
println("Bike unlocked!")
}
override fun onError(error: MosaError) {
println("Error: ${error.message}")
}
// Implement other callbacks...
}
)
}
}
MosaDockSDK.initialize(
with: self,
apiKey: "your-api-key",
userId: "user-123"
)
let sdk = MosaDockSDK.shared
Task {
do {
let unlockKey = try await sdk.requestUnlockKey(
type: .bikeUnlock,
areaId: "area-123",
userId: "user-123"
)
try await sdk.unlockSmartLock(
with: unlockKey,
location: .parking,
delegate: self
)
} catch {
print("Error: \(error)")
}
}
final mosaDockSdk = MosaDockSdk();
await mosaDockSdk.initialize(
apiKey: 'your-api-key',
userId: 'user-123',
);
mosaDockSdk.dockCallbackEvents.listen((event) {
if (event.type == DockCallbackType.dockUnlocked) {
print('Bike unlocked!');
} else if (event.type == DockCallbackType.error) {
print('Error: ${event.message}');
}
});
try {
final unlockKey = await mosaDockSdk.requestUnlockKey(
type: MosaDockUnlockKeyType.bikeUnlock,
areaId: 'area-123',
userId: 'user-123',
);
await mosaDockSdk.handleClientUnlock(
unlockKey: unlockKey,
locationType: MosaDockLocationType.parking.value,
);
} catch (e) {
print('Error: $e');
}
Getting Help
- Support - Support channels and help
- Testing and Debugging - Troubleshooting guide
- API Reference - Complete API documentation
For more examples, see the Use Case Guides.