⌘K

NativeblocksManager

Manages the lifecycle, configuration, and dynamic composition capabilities of the Nativeblocks framework. This manager enables you to initialize Nativeblocks, register blocks, actions, loggers, type converters, and manage frame data and global parameters.


NativeblocksEdition

Defines the available editions for Nativeblocks:

  • NativeblocksEdition.Cloud: Cloud-based configuration.

    • endpoint: The API endpoint for fetching frames/resources.
    • apiKey: The API key for authentication.
    • developmentMode: Enable development features.
  • NativeblocksEdition.Community: Community-based configuration.

    • framesData: Map of route keys to local frame data URLs/paths.

NativeblocksManager

A singleton-class (per name/instance) responsible for managing Nativeblocks SDK configuration and component registration.

Initialization & Instance Management

initialize

Initializes the Nativeblocks framework for a given instance name.

NativeblocksManager.initialize(
    name: String = "default",
    applicationContext: Context,
    edition: NativeblocksEdition
)
  • Throws: IllegalArgumentException if name contains invalid characters.

getInstance

Retrieves the manager instance by name (default: "default").

NativeblocksManager.getInstance(name: String = "default"): NativeblocksManager
  • Throws: IllegalStateException if not initialized.

isInitialized

Checks if a manager instance has been initialized.

NativeblocksManager.isInitialized(name: String = "default"): Boolean

Wandkit Setup

wandkit

Configures one or more Wandkit(s).

fun wandKit(vararg wandkit: WandKit): NativeblocksManager

Block Registration

provideBlock

Registers a block implementation by type.

fun provideBlock(blockType: String, block: @Composable (blockProps: BlockProps) -> Unit): NativeblocksManager

provideFallbackBlock

Registers a composable to be used when a requested block type/key is not found.

fun provideFallbackBlock(block: @Composable (keyType: String, key: String) -> Unit): NativeblocksManager

Action Registration

provideAction

Registers an action implementation by type.

fun provideAction(actionType: String, action: INativeAction): NativeblocksManager

provideActionContractor

Registers an action contractor (handles complex action flows).

fun provideActionContractor(actionContractor: INativeActionContractor): NativeblocksManager

provideFallbackAction

Registers a fallback handler for unsupported or unrecognized actions.

fun provideFallbackAction(block: (keyType: String, name: String) -> Unit): NativeblocksManager

Logger Registration

provideEventLogger

Registers an event logger for instrumentation/tracking.

fun provideEventLogger(loggerType: String, logger: INativeLogger): NativeblocksManager

Frame Data Management

syncFrame

Synchronizes a frame with the remote backend.

suspend fun syncFrame(frameRoute: String): NativeblocksManager

clearAllFrames

Clears all frame data from the cache.

suspend fun clearAllFrames(): NativeblocksManager

clearFrame

Clears a specific frame route from the cache.

suspend fun clearFrame(frameRoute: String): NativeblocksManager

Localization & Global Parameters

setLocalization

Sets the language code for localization (e.g. "EN", "FA").

fun setLocalization(languageCode: String): NativeblocksManager

setGlobalParameters

Sets global key-value parameters for frames.

fun setGlobalParameters(vararg parameters: Pair<String, String>): NativeblocksManager
fun setGlobalParameters(parameters: Map<String, String>): NativeblocksManager

Landing & Experiment

getLanding

Retrieves the landing string by the provided landing name.

suspend fun getLanding(name: String): Result<String>

getExperiment

Retrieves the experiment value for the provided key as type T. Supports only the following types:

  • STRING: String
  • NUMBER: Int, Float, Double, Long
  • BOOLEAN: Boolean
  • JSON: String (as raw JSON)

If the requested type doesn't match the experiment type, defaultValue will be returned.

suspend fun <T : Any> getExperiment(key: String, defaultValue: T): T

Type Converter Registration & Retrieval

provideTypeConverter

Registers a type converter for a given type.

fun <T : Any> provideTypeConverter(type: KClass<T>, converter: INativeType<T>): NativeblocksManager

getTypeConverter

Retrieves the type converter for a given type.

fun <T : Any> getTypeConverter(type: KClass<T>): INativeType<T>
  • Throws: Exception if converter not provided.

Scaffold, Cleanup, & Destroy

getScaffold

Retrieves the current scaffold (frames list/structure) for the configuration.

suspend fun getScaffold(): Result<NativeScaffoldModel>

destroy

Destroys the NativeblocksManager instance and cleans up associated resources.

fun destroy()

NativeblocksFrame

Composable for rendering a Nativeblocks frame.

@Composable
fun NativeblocksFrame(
    instance: String = "default",
    frameRoute: String,
    routeArguments: Map<String, String>,
    loading: @Composable () -> Unit,
    error: @Composable (String) -> Unit
)

NativeblocksLoading

Composable for rendering a loading indicator.

@Composable
fun NativeblocksLoading()

NativeblocksError

Composable for rendering error messages.

@Composable
fun NativeblocksError(message: String)

NativeblocksResourceManager

Handles resources such as font families.

provideFontFamily

Registers a custom font family by name.

fun provideFontFamily(fontName: String, fontFamily: FontFamily): NativeblocksResourceManager

NativeScaffoldModel

Describes the scaffold structure—typically contains a list of frame routes.

  • frames: List of frame route models.

NativeFrameRouteModel

Describes a single frame route:

  • id: Unique identifier
  • name: Display name
  • type: Frame type (FRAME, BOTTOM_SHEET, DIALOG)
  • route: Route path
  • isStarter: Is starter frame
  • routeArguments: List of route arguments

NativeRouteArgumentsModel

Represents an argument for a route:

  • name: Argument name

FrameTypeModel

Enum of supported frame types:

  • FRAME
  • BOTTOM_SHEET
  • DIALOG