tencent cloud

Tencent Cloud Super App as a Service

계약
데이터 처리 및 보안 계약
문서Tencent Cloud Super App as a Service

SDK Integration

포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-02-10 19:54:17
This doc will guide client developers in integrating a lightweight mini program SDK that allows mini programs to be opened.

Integration process

1. Configure the repository address in settings.gradle

pluginManagement {
repositories {
maven {
url 'https://maven-dev.tcmppcloud.com/fHKFBbEjd/repository/maven-public/'
}
}
}
dependencyResolutionManagement {
repositories {
maven {
url 'https://maven-dev.tcmppcloud.com/fHKFBbEjd/repository/maven-public/'
}
}
}

2. Add Kotlin plugin configuration to build.gradle of the application module

plugins {
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.kapt"
}

3. Configure packagingOptions in build.gradle of the application module

android {
defaultConfig {
packagingOptions{
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libwechatxlog.so'
pickFirst 'lib/armeabi/libwechatxlog.so'
pickFirst 'lib/armeabi-v7a/libwechatxlog.so'
}
}
}

4. Configure mini program SDK dependencies

dependencies {
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'androidx.core:core-ktx:1.6.0'
//gosn
implementation 'com.google.code.gson:gson:2.8.6'
// ok-http
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
// mini app start
// Annotation processor (required)
kapt 'com.tencent.tcmpp.android:mini_annotation_processor:${version}' // For version information, see Android SDK updates
// Core library (required)
implementation 'com.tencent.tcmpp.android:mini_core:${version}' // For version information, see Android SDK updates
// Preset base library (optional)
implementation 'com.tencent.tcmpp.android:mini_baselib:${version}' // For version information, see Android SDK updates
// mini app end
}
Note:
Replace {version} in the configuration with the corresponding version of the dependencies. For version information, see Android SDK updates.
If developers have used the annotationProcessor annotation processor in their original projects, they need to change all annotationProcessor entries to kapt annotation processors.
Once the dependencies for the mini program SDK are added, you can begin integrating the mini program SDK as described in the following sections.

Preparation before integration

1. Obtain the configuration file

The initialization of the mini program SDK relies on a configuration file from the console. Before integrating the mini program SDK, you need to obtain this configuration file.
The process for obtaining the configuration file is as follows:
1.1 Log in to the console
1.2 Create a superapp

1.3. Fill in the superapp information
Required information:
Superapp name: Supports 3-64 characters including a-z, A-Z, 0-9, spaces and some special symbols ("+", "=", ",", ".", "@", "-", "_").
Optional information:
Superapp description: Brief introduction of the superapp, primarily for internal reference.
Superapp icon: Supports uploading square images in .jpg or .png format, with a resolution of 128 × 128 and a file size under 2 MB. If the icon is not uploaded, the system default icon will be used.
Scheme: Only supports lowercase letters and numbers, up to 64 characters. Once the scheme is configured, the QR code of the mini program (or mini game) will include this scheme. Using the phone system’s built-in scanning function, users can directly launch superapp and open the mini program (or mini game).



1.4 Enter the superapp package name
The following fields need to be filled in when adding the package name/bundle ID:
Type: Once selected, the type cannot be changed. Package names for non-production types are only used for superapp test versions and have a monthly device usage limit (up to 500 devices).
Package name/bundle ID: Only supports lowercase letters (a-z), numbers (0-9), dots (.), and hyphens (-), up to 255 characters. It is recommended to use reverse domain name notation, such as com.example.myapp.
Download URL: Only supports uppercase letters (A-Z), lowercase letters (a-z), numbers (0-9), dots (.), hyphens (-), and slashes (/), up to 2,048 characters.


1.5 Download the configuration file
Note:
The default name of the downloaded configuration file is tcsas-android-configurations.json.


2. Add the configuration file to the project

After obtaining the configuration file, you need to copy the configuration file to the assets directory of your project.

Note:
Ensure the superapp package name matches the one configured in the console. Otherwise, the mini program SDK will fail to validate the package name at runtime, leading to SDK errors.

3. Add mini program SDK initialization configuration in the source code

Extend and implement the MiniConfigProxy class.
Add the following annotations for the implementation class of MiniConfigProxy:
@ProxyService(proxy = MiniConfigProxy.class)
Example:
@ProxyService(proxy = MiniConfigProxy.class)
public class MiniConfigProxyImpl extends MiniConfigProxy {
/**
* Obtains the Application instance of the superapp
* Note: 1. The mini program adopts a multi-process architecture. Ensure that sub-processes can also properly access the Application instance.
* 2. It is recommended to cache the Application instance in Application.attachBaseContext
* to prevent the SDK from obtaining a null Application instance due to component timing issues.
* @return
*/
@Override
public Application getApp() {
// Must use the Application instance of the superapp
return "your superapp Application";
}

/**
* Creates initialization configuration information
* @return
*/
@Override
public MiniInitConfig buildConfig() {
MiniInitConfig.Builder builder = new MiniInitConfig.Builder();
MiniInitConfig config = builder
.configAssetName("tcsas-android-configurations.json") // Configuration file name in assets
.autoRequestPermission(true) // Whether to automatically request system permissions for APIs that require permissions
.debug(true) // Log switch, default is off
.build();
return config;
}
}
Note:
1. The configAssetName in MiniConfig is used to specify the path and name of the configuration file in the source code project.
2. Since the SDK initially retrieves the superapp's Application instance from an internal ContentProvider, it is recommended to cache the Application instance in the Application.attachBaseContext method. This prevents the SDK from obtaining a null Application instance due to timing issues.
At this point, the integration of the mini program SDK is complete. The next step is to use the APIs provided by the mini program SDK to open and preview mini programs.

Open a mini program

To open a mini program, use the following code:
Note:
The appid is the mini program appid, which needs to be obtained from the mini program developer.
TmfMiniSDK.startMiniApp(activity, appId, new MiniStartOptions());

Implement the image loading API

To allow superapps to centrally manage and control image loading, the mini program SDK does not provide a default image loading feature. Instead, it offers a proxy API for superapps to implement image loading. If a superapp does not implement image loading, the following features may display abnormally:
Mini program icons in the capsule panel
Mini program icons in authorization pop-ups
Mini program icons on the loading page
Mini program icons on the About page
The video component cover
The cover-image image
The profile photo
For details on the image loading implementation method, see: Image loading API.

Mini program data is stored separately by user account

If your superapp supports multiple user logins and you need to prevent mini program sandbox data from being shared across different users, you need to implement the IMiniAppProxy.getAccount() method to return a differentiated user ID. This enables sandbox data to be isolated and stored per account.
For setup instructions and important notes, please see: Setting the User ID


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백