tencent cloud

其他

PDF
聚焦模式
字号
最后更新时间: 2026-03-20 18:44:06

Superapp 相关接口

/**
* @brief Superapp应用名称 - Superapp name
* 此 API 提供用于文本显示的superapp名称 - Mainly used for copywriting prompts
*/
- (NSString *)appName;

/**
* @briefSuperapp版本 - Superapp version
* @return 返回的是小写字符串,例如1.0.0 - 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 Superapp基础信息 - Get 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 Superapp设置的当前语言 - Get current language set by the Superapp
* @return 格式 - format : "zh-Hans"
*/
- (NSString *)getCurrentLocalLanguage;


/**
* @brief Superapp设置的当前主题 如果不实现此方法 那么getAppBaseInfo中返回的theme为系统主题 - The current theme set by 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

// 小程序最多保活的个数,默认是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;

截屏、录屏事件和添加水印

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

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

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

web-view 组件中特殊链接处理

对于 web-view 组件页面中要处理的特殊链接透传至宿主 app,由宿主 app 进行处理。
// web-view组件中跳转非http/https时触发,用于处理web-view组件中特殊url的情况,比如打开其它App - Triggered when redirecting to non-http/https in the web-view component. Used to handle special URLs in the web-view component, such as opening other apps.
// @param app {TMFMiniAppInfo} web-view组件所在的小程序信息 - Mini-program information where the web-view component is located
// @param url {NSURL} 要打开的url - The url to open
// @return 是否拦截处理 - Whether to intercept processing
- (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;
}

iOS18及以上系统使用HTTP资源兼容

Superapp 可以配置关闭所有小程序调试功能,包括小程序调试开关及远程调试。
//TMFMiniAppSDKDelegate protocol
- (NSString *)stringWithConfigKey:(NSString *)key {
if([key isEqualToString:TMA_SK_MINIAPP_ATS_Allow_Arbitrary_Loads]) {
return @"1";
}
return nil;
}

禁用小程序调试相关功能

Superapp 可以通过代理接口设置,禁用所有小程序调试相关功能,包括小程序调试入口及远程调试。

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

iOS26及以上修改导航栏按钮显示样式

iOS26及以上系统默认导航栏按钮为毛玻璃显示效果,superapp 可以通过代理接口设置,关闭该效果显示,保持与之前版本一致。

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


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈