The SDK for the mini-app provides several methods for interacting with the mini-program. Before getting started, please apply for access to the mini-program functionality on the mini-program open platform and register your mini-app. Here are some common usage examples:
Set Theme Style
miniAppService.updateTheme(userInterfaceStyle: .dark)
Set Language
miniAppService.updateLanguage(languageCode: "zh")
Launch Params
WebAppLaunchWithParentParameters.Builder()
.parentVC(self)
.url("https://game.bt.qiku.net/games/fruittri?code=LuLT2PdXscbH3TOmTpX+LVnPClMHSZFa66v7ygw40CExOCQXfkUaBZzEeM+hoOtW&channel=telegram&lan=zh-hans")
.isLaunchUrl(false)
.isLocalSource(false)
.autoExpand(true)
.startParams("Your webapp startParam")
.useCache(true)
.useModalStyle(false)
.useCustomNavigation(false)
.getInputContainerNode(inputNode)
.didDismiss({
})
.completion({
})
.build()
Here is an explanation of the parameters used in the WebAppLaunchWithParentParameters.Builder()
:
parentVC(self)
: Specifies the parent view controller for launching the web app.url(url)
: Sets the URL of the web app to be launched.isLaunchUrl(false)
: Indicates whether the URL should be launched.isLocalSource(false)
: Specifies if the web app source is local or not.autoExpand(true)
: Determines if the web app should automatically expand.startParams("Your webapp startParam")
: Sets the start parameters for the web app.useCache(true)
: Specifies whether caching should be used.useModalStyle(false)
:Page style setting, default is full-screen mode.useCustomNavigation(false)
:Toolbar style setting, default style and custom style.getInputContainerNode(inputNode)
: Retrieves the input container node for the web app.didDismiss({})
: Sets a callback for when the web app is dismissed.completion({})
: Sets a callback for when the web app launch is completed.
Preload Mini App with botName and miniAppName
val config = WebAppPreloadParameters.Builder()
.botName("MatrixBot102")
.miniAppName("cybercat")
.build()
miniAppService?.preload(config)
Preload Mini App with URL
val config = WebAppPreloadParameters.Builder()
.url("https://mini-app-me-host/botName/miniAppName")
.build()
miniAppService?.preload(config)
Launch Mini App with botName and miniAppName
val config = WebAppLaunchWithDialogParameters.Builder()
.parentVC(viewController)
.botName("MatrixBot102")
.miniAppName("cybercat")
.didDismiss(didDismiss)
.build()
miniAppService?.launch(config)
Launch Mini App with URL
val config = WebAppLaunchWithDialogParameters.Builder()
.parentVC(viewController)
.url("https://mini-app-me-host/botName/miniAppName")
.didDismiss(didDismiss)
.build()
miniAppService?.launch(config)
Embed Mini App with botName and miniAppName into a Container
val config = WebAppLaunchWithParentParameters.Builder()
.parentVC(viewController)
.botName("MatrixBot102")
.miniAppName("cybercat")
.didDismiss(didDismiss)
.getInputContainerNode(inputContainerNode)
.build()
miniAppService?.launch(config)
Embed Mini App with URL into a Container
val config = WebAppLaunchWithParentParameters.Builder()
.parentVC(viewController)
.url("https://mini-app-me-host/botName/miniAppName")
.didDismiss(didDismiss)
.getInputContainerNode(inputContainerNode)
.build()
miniAppService?.launch(config)