tencent cloud

Tencent Cloud Super App as a Service

ドキュメントTencent Cloud Super App as a Service

Others

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-07-02 20:13:16

Superapp APIs

/**
* @brief The superapp name
* This API provides the superapp name for display in text.
*/
- (NSString *)appName;

/**
* @brief The superapp version
* @return Returns a lowercase string, such as 1.0.0.
*/
- (NSString *)getAppVersion;

/**
* @brief The network status
*/

- (TMANetWorkStatus)getAppNetworkStatus;

/**
* @brief The model information
*/
- (NSString *)getAppIPhoneModel;

/**
* @brief The device information
* @return Format: {@"brand":@"iPhone",@"model":@"iPhone 11<iPhone12,1>",@"system":@"ios",@"platform":@"iOS 16.4.1"}
*/
- (NSDictionary *)getAppDeviceInfo;
/**
* @brief Gets basic information of the superapp
* @return Format: {@"SDKVersion":@"2.32.2",@"model":@"iPhone 11<iPhone12,1>",@"system":@"ios",@"platform":@"iOS 16.4.1"}
*/
- (NSDictionary *)getAppBaseInfo;

/**
* @brief Gets the current language set in the superapp
* @return Format: "zh-Hans"
*/
- (NSString *)getCurrentLocalLanguage;


/**
* @brief The current theme set in the superapp. If this method is not implemented, the theme returned in getAppBaseInfo will be the system theme.
*/
- (NSString *)getAppTheme;

/**
* @brief Clipboard frequency control
*/
- (NSNumber *)getClipboardInterval

// The maximum number of active mini programs. Default value: 3.
// The maximum number of mini programs that can be kept alive, the default is 3
- (NSInteger)maxMiniAppKeepAliveCount;

// Superapp URL Scheme
// Set the superapp URL Scheme
- (NSString *)getAppScheme;

Screen capture, screen recording and watermarking

- (void)applet:(TMFMiniAppInfo *)appletInfo screenCaptureStatusChanged:(BOOL)isCapture atPagePath:(NSString *)pagePath;

- (void)appletDidTakeScreenshot:(TMFMiniAppInfo *)appletInfo atPagePath:(NSString *)pagePath;

- (nullable UIView *)appletCustomizeWatermarkView:(TMFMiniAppInfo *)appletInfo;

Process special URLs in web-view component

Special URLs in web-view component pages should be passed to the superapp for processing.
// Triggered when redirecting to non-http/https in the web-view component. It is used to process special URLs in the web-view component, such as opening other apps.
// @param app {TMFMiniAppInfo} Information about the mini program where the web-view component is located.
// @param url {NSURL} The URL to be accessed.
// @return Whether to intercept.
- (BOOL)webViewCustomUrlLoading:(TMFMiniAppInfo *)app url:(NSURL *)url {
NSLog(@"webViewCustomUrlLoading:%@,appid:%@",[url absoluteString],app.appId);
if ([[UIApplication sharedApplication] canOpenURL:url]) {
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"webViewCustomUrlLoading:%@,appid:%@, open sucess",[url absoluteString],app.appId);
}
}];
} else {
[[UIApplication sharedApplication] openURL:url];
}
return YES;
} else {
NSLog(@"webViewCustomUrlLoading:%@,appid:%@,cann't open!!!",[url absoluteString],app.appId);
}
return NO;
}

Compatibility for HTTP resources on iOS 18 and above

Superapp can be configured to disable all mini program debugging features, including debug switches and remote debugging.
//TMFMiniAppSDKDelegate protocol
- (NSString *)stringWithConfigKey:(NSString *)key {
if([key isEqualToString:TMA_SK_MINIAPP_ATS_Allow_Arbitrary_Loads]) {
return @"1";
}
return nil;
}

Disable mini-program debugging features

Superapp can be configured to disable all mini program debugging-related features, including debug entrance and remote debugging, via delegate API.

//TMFMiniAppSDKDelegate protocol
- (NSString *)stringWithConfigKey:(NSString *)key {
if([key isEqualToString:TMA_SK_MINIAPP_EnableDebug_Allow]) {
return @"0";
}
return nil;
}

Change the display style of navigation bar buttons in iOS 26 and above

On iOS 26 and above, the navigation bar buttons have a frosted glass effect by default. The superapp can be configured to disable this effect via delegate API to maintain consistency with previous versions.

//TMFMiniAppSDKDelegate protocol
- (NSString *)stringWithConfigKey:(NSString *)key {
if([key isEqualToString:TMA_SK_MINIAPP_NavigationItem_HidesSharedBackground]) {
return @"1";
}
return nil;
}

Customize the web-view component error page

When the web-view component loads a domain that is not on the allowlist, the SDK displays an error page. Starting from version 2.3.9, you can replace it with a custom page. If not configured, the SDK falls back to the built-in error page.
Usage
Implement stringWithConfigKey: in TMFMiniAppSDKDelegate and return the local absolute path to the custom error page:

- (NSString *)stringWithConfigKey:(NSString *)key {
if ([key isEqualToString:TMA_SK_MINIAPP_WebView_DomainError_PagePath]) {
return [[NSBundle mainBundle] pathForResource:@"my_error_page"
ofType:@"html"
inDirectory:@"Resource/jssdk"];
}
return nil;
}
The error page receives the intercepted domain or message through the URL parameter ?msg=<URL-encoded message>. Decode it on the frontend for display:

<script>
var msg = decodeURIComponent(new URLSearchParams(location.search).get('msg') || '');
document.getElementById('tip').innerText = msg;
</script>

Note:
The path must be a local file absolute path. Remote URLs are not supported.
If nil, an empty string, or an unreadable file path is returned, the SDK falls back to the built-in error page.

Dynamically inject JS into mini games

Supports the superapp injecting a custom JS prelude into a mini game during cold start. The injection occurs after the base library finishes loading but before the game code (game.js) executes. This can be used to preset global variables, mock APIs, or set up event tracking.
Usage
Implement the following method in TMFMiniAppSDKDelegate and return the JS to inject. Return nil or an empty string to skip injection:

- (nullable NSString *)miniGameJSPreludeForAppInfo:(TMFMiniAppInfo *)appInfo {
// Differentiate mini games by appInfo.appId
return @"(function(){ globalThis.__HOST_ENV__ = { channel: demo' }; })();";
}
Notes:
Note:
This method is called only once during cold start. It is not triggered during warm start. It only applies to mini games.
The injected JS shares the global namespace with game.js. Wrapping it in an IIFE (function(){ ... })(); is recommended.
The wx APIs are already available at injection time. Exceptions thrown by the injected JS do not block game loading.



ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック