Native

To use Sandbox App for developing your native mini-app integration, you need to:

  • Download the Sandbox App source code
  • Add your native mini-app source code or pre-built artifacts (aar/framework) and built it along with the Sandbox App source code
  • Enjoy developing!

Detail instructions are below

Clone the Sandbox Application#

The Android Sandbox App source code has been updating here

Project structure#

  • Module sandbox : This module was configured the as Terra Super-app. We install all required dependencies and prepared sevaral test scenarios for mini-app team.
  • Module connector: where the mini-app teams can setup input, output to open their application.
  • Other modules: Just for demo.

Open your mini-app#

Step 1: Import your module#

In order to open your mini-app, you should import your module to module connector

  • If you use aar file or published your artifact then configure to pull your dependencies in connector.build.gradle.kts.

  • Or setup your module as a local module of sandbox (either by using git submodule or just by copying folder) then update setting.gradle.kts and connector.build.gradle.kts to import local module, so you can build & debug your mini-app-module directly. The project structure looks like below:

Step 2: Open the first actitivy of your mini-app#

Searching in whole project to open file vn.teko.sandbox.connector.NativeConnector

/**
* This is where you can configure data to open your first mini-app screen
*/
internal class NativeConnector : AndroidNativeAppLauncher {
/**
* Reconfigure the intent to open your activity here
* For a simple example: return Intent(application, YourMiniAppActivity::class.java)
*
* @param application: Application that was used to open new activity
* @param launcherData: Containing exchanged token and some extra data that you want to dynamic
* config your mini-app
* @return Intent
*/
override suspend fun create(application: Application, launcherData: AppLauncherData): Intent {
val authResult = launcherData.authResult as? IdTokenExchangeAuthResult
val extraConfig = launcherData.extraConfig
// Place a Intent here to open your mini app
return DemoMiniAppSdk.createInstance(
application,
DemoMiniAppSdk.Config(
idToken = authResult?.idToken,
name = getConfigByKey(extraConfig, NAME_KEY),
address = getConfigByKey(extraConfig, ADDRESS_KEY),
)
)
}
private fun getConfigByKey(config: Map<String, String>, key: String) = config[key] ?: ""
companion object {
private const val NAME_KEY = "name"
private const val ADDRESS_KEY = "address"
}
}

The function create(application: Application, launcherData: AppLauncherData) return a Intent to open the activity of your mini-app, so you can remove the example code and place your Intent instead.

Please note that this is just the quickstart guide, in reality you will need to change the package of this connector class to avoid conflicts.