WandKit
WandKit is a robust framework designed to enhance your Android application development by enabling features like screen sharing, live session management, and seamless integration with Nativeblocks Studio. This guide covers the installation, configuration, and usage of WandKit and its key component, LiveKit.
Get Started
Requirements
Ensure your project meets the following requirements:
- Minimum Android SDK: 26 (Lollipop) or higher.
- Development Language: Kotlin.
- Initialized Nativeblocks Core SDK: Ensure the Nativeblocks SDK is properly initialized in your application.
Install WandKit
Add the WandKit dependency to your build.gradle file:
implementation("io.nativeblocks:nativeblocks-wandkit-android:1.0.0")
Best Practices
-
Use Debug-Only Features Wisely:
- Restrict LiveKit's screen sharing and debugging capabilities to non-production builds.
-
Optimize Resource Usage:
- Always call destroy() on LiveKit when it is no longer needed to release resources.
LiveKit
LiveKit is a core component of WandKit that offers functionalities such as screen sharing, keeping the screen active, and auto-connecting to the Nativeblocks Studio environment.
Required Permissions
Add the following permissions to your AndroidManifest.xml to ensure all features of WandKit work as expected:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Permission Descriptions
- FOREGROUND_SERVICE: Required to run a foreground service for live session handling.
- FOREGROUND_SERVICE_REMOTE_MESSAGING: Ensures compatibility with remote messaging while using foreground services.
- CAMERA: Enables features that require camera access, such as screen sharing.
- POST_NOTIFICATIONS: Allows sending notifications to the user, often used for live session updates.
Ensure you provide appropriate justifications for these permissions in your app's privacy policy and during runtime permission requests.
Initialization
Initialize LiveKit in your application class or via dependency injection. Ensure that LiveKit is configured after the Nativeblocks SDK is initialized.
Restrict the usage of LiveKit to debug builds to avoid unintended behavior in production:
import android.app.Application
import io.nativeblocks.core.api.NativeblocksManager
import io.nativeblocks.wandkit.LiveKit
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Nativeblocks SDK
NativeblocksManager.initialize()
// Configure LiveKit
if (BuildConfig.DEBUG) {
NativeblocksManager.getInstance().liveKit(
screenSharing = true,
keepScreenOn = true,
autoConnect = true
)
}
}
}