AppKit is a singleton that interacts with the AppKit SDK.
Implementation#
Initialize#
val connectionType = ConnectionType.AUTOMATIC or ConnectionType.MANUALval projectId = "" // Get Project ID at https://dashboard.reown.com/val appMetaData = Core.Model.AppMetaData( name = "Kotlin.AppKit", description = "Kotlin AppKit Implementation", url = "kotlin.reown.com", icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media"), redirect = "kotlin-modal-wc://request")CoreClient.initialize(projectId = projectId, connectionType = connectionType, application = this, metaData = appMetaData)AppKit.initialize( init = Modal.Params.Init(CoreClient), onSuccess = { // Callback will be called if initialization is successful }, onError = { error -> // Error will be thrown if there's an issue during initialization })Session properties#
You can define session properties by calling the setSessionProperties method on the AppKit object.
Chains#
This example of define ethereum chain. You can define the chains you want to use. The chain must be EVM compatible.
Example of definition chains: https://github.com/reown-com/reown-kotlin/blob/main/product/appkit/src/main/kotlin/com/reown/appkit/presets/AppKitChainsPresets.ktAppKit.setChains(AppKitChainsPresets.ethChains.values.toList())IMPORTANT: Chains must be set before opening the modal.
Usage#
import androidx.compose.material.ExperimentalMaterialApiimport androidx.compose.material.ModalBottomSheetStateimport androidx.navigation.compose.NavHostimport androidx.navigation.compose.composableimport androidx.navigation.compose.rememberNavControllerimport com.google.accompanist.navigation.material.BottomSheetNavigatorimport com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApiimport com.google.accompanist.navigation.material.ModalBottomSheetLayoutimport com.google.accompanist.navigation.material.bottomSheetimport com.reown.appkit.ui.appKitGraphsetContent { val modalSheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden, skipHalfExpanded = true) val bottomSheetNavigator = BottomSheetNavigator(modalSheetState) val navController = rememberNavController(bottomSheetNavigator) ModalBottomSheetLayout(bottomSheetNavigator = bottomSheetNavigator) { NavHost( navController = navController, startDestination = "home" ) { composable("home") { HomeScreen() } appKitGraph(navController) } }}IMPORTANT: AppKit uses accompanist navigation material inside. ModalBottomSheetLayout should be imported from Accompanist Navigation Material
import com.reown.appkit.ui.openAppKitnavController().openAppKit( shouldOpenChooseNetwork = true | false onError = { })import androidx.compose.material.ExperimentalMaterialApiimport androidx.compose.material.ModalBottomSheetStateimport androidx.navigation.compose.NavHostimport androidx.navigation.compose.composableimport androidx.navigation.compose.rememberNavControllerimport androidx.compose.material.ModalBottomSheetLayoutsetContent { val modalSheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden, skipHalfExpanded = true) val coroutineScope = rememberCoroutineScope() val navController = rememberNavController() ModalBottomSheetLayout( sheetContent = { AppKitComponent( shouldOpenChooseNetwork = true | false, closeModal = { coroutineScope.launch { modalSheetState.hide() } ) } ) { // content }}import androidx.navigation.createGraphimport androidx.navigation.fragment.fragmentimport com.reown.appkit.ui.appKitGraphnavController.graph = navController.createGraph("Home") { fragment<HomeFragment>("Home") appKit()}import androidx.navigation.fragment.findNavControllerimport com.reown.appkit.ui.openAppKitfindNavController().openAppKit( shouldOpenChooseNetwork = true | false onError = { })<navigation > <fragment android:id="@+id/HomeFragment" android:name="com.reown.sample.HomeFragment"> </fragment> <include app:graph ="@navigation/appkit_graph"/></navigation>import androidx.navigation.fragment.findNavControllerimport com.reown.appkit.ui.openAppKitfindNavController().openAppKit( shouldOpenChooseNetwork = true | false onError = { })