TokenBundleRepositoryImpl

class TokenBundleRepositoryImpl<T>(registry: WearDataLayerRegistry, key: String = DEFAULT_TOKEN_BUNDLE_KEY, coroutineScope: CoroutineScope, serializer: Serializer<T>) : TokenBundleRepository<T>

Default implementation for TokenBundleRepository.

If multiple token bundles are required to be shared, specify a key in order to identify each one, otherwise the same default key will be used and only a single token bundle will be persisted.

Samples

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.lifecycle.lifecycleScope
import androidx.wear.watchface.complications.data.ComplicationType
import com.google.android.horologist.datalayer.watch.WearDataLayerAppHelper
import kotlinx.coroutines.launch
fun main() { 
   //sampleStart 
   class MainActivity : ComponentActivity() {
    private lateinit var wearDataLayerAppHelper: WearDataLayerAppHelper
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        wearDataLayerAppHelper = WearDataLayerAppHelper(
            context = this,
            registry = (application as SampleApplication).registry,
            scope = lifecycleScope,
        )

        lifecycleScope.launch {
            wearDataLayerAppHelper.markTileAsInstalled("MyTile")
            wearDataLayerAppHelper.markComplicationAsActivated(
                complicationName = "MyComplication",
                complicationInstanceId = 1234,
                complicationType = ComplicationType.SHORT_TEXT,
            )
            wearDataLayerAppHelper.markActivityLaunchedOnce()
        }

        setContent {
            WearApp()
        }
    }
} 
   //sampleEnd
}

Constructors

Link copied to clipboard
constructor(registry: WearDataLayerRegistry, key: String = DEFAULT_TOKEN_BUNDLE_KEY, coroutineScope: CoroutineScope, serializer: Serializer<T>)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun isAvailable(): Boolean

Check if this repository is available to be used on this device.

Link copied to clipboard
open suspend override fun update(tokenBundle: T)