Perjanjian Pemrosesan dan Keamanan Data
//TCSAS#import <TCMPPSDK/TCMPPSDK.h>
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"tcsas-ios-configurations" ofType:@"json"];if(filePath) {TMAServerConfig *config = [[TMAServerConfig alloc] initWithFile:filePath];[[TMFMiniAppSDKManager sharedInstance] setConfiguration:config];}
[TMFMiniAppSDKManager sharedInstance].miniAppSdkDelegate = [MIniAppDemoSDKDelegateImpl sharedInstance];
// Open the mini program using the mini program appid// @param appID Mini program appid// @param verType The version type of the mini program to open// @param scene Scene value// @param firstPage The first page of the mini program to open// @param paramsStr The parameter used to open the mini program// @param parentVC The view controller from which to present the scan view controller// @param completion Error callback- (void)startUpMiniAppWithAppID:(NSString *)appIDverType:(TMAVersionType)verTypescene:(TMAEntryScene)scenefirstPage:(NSString * _Nullable)firstPageparamsStr:(NSString * _Nullable)paramsStrparentVC:(UIViewController *)parentVCcompletion:(void (^)(NSError * _Nullable))completion;
Name | Required | Type | Description |
appID | True | NSString | The appid of the mini program to open. |
verType | True | TMAVersionType | The type of the mini program to open. |
scene | True | TMAEntryScene | The scene value for opening the mini program. |
firstPage | False | NSString | The first page of the mini program to open. |
paramsStr | False | NSString | The parameters to pass when opening |
parentVC | True | UIViewController | The view controller from which to present the scan view controller. |
completion | True | block | Error callback. |
[[TMFMiniAppSDKManager sharedInstance] startUpMiniAppWithAppID:info.appIdverType:TMAEntrySceneNonescene:TMAEntrySceneAIOEntryfirstPage:nilparamsStr:[NSString stringWithFormat:@"noServer=%@",noServerStr]parentVC:selfcompletion:^(NSError * _Nullable error) {}];
[[TMFMiniAppSDKManager sharedInstance] startUpMiniAppWithQRCodeWithParentVC:self completion:^(NSError * _Nullable err) {}];



- (NSString *)getAppScheme{return @"tcsas";}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {if ([[TMFMiniAppSDKManager sharedInstance] handleOpenUrl:url]){return YES;}return YES;}
[[TMFMiniAppSDKManager sharedInstance] searchAppletsWithName:@"" completion:^(NSArray<TMFAppletSearchInfo *> * _Nonnull result, NSError * _Nonnull aError) {}];
// Get information about all recently opened mini programs///@return An array of mini programs <TMFMiniAppInfo>- (NSArray *)loadAppletsFromCache;
NSArray *list = [[TMFMiniAppSDKManager sharedInstance] loadAppletsFromCache];self.recentList = [NSMutableArray arrayWithArray:list];if (self.demoList) {[self.demoList removeAllObjects];} else {self.demoList = [[NSMutableArray alloc] init];}[[TMFMiniAppSDKManager sharedInstance] searchAppletsWithName:@"" completion:^(NSArray<TMFAppletSearchInfo *> * _Nullable datas, NSError * _Nullable error) {[self.demoList addObjectsFromArray:datas];if (self.selectIndex == 0) {self.dataSource = self.demoList;}[self.tableView reloadData];}];


/*** @brief Gets current language set by the superapp* @return Format: "zh-Hans"*/- (NSString *)getCurrentLocalLanguage;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {NSString *language = @"en";if (indexPath.row == 0) {language = @"zh-Hans";} else if (indexPath.row == 1) {language = @"en";} else if (indexPath.row == 2) {language = @"fr";} else if (indexPath.row == 3) {language = @"id";}[[LanguageManager shared] setCurrentLanguage:language];/// Note that you need to terminate all mini programs[[TMFMiniAppSDKManager sharedInstance] terminateAllApplications];}
- (NSString *)getCurrentLocalLanguage {return [[LanguageManager shared] currentLanguage];}
- (NSString *)getAppUID {return [DemoUserInfo sharedInstance].userId;}
[[TMFMiniAppSDKManager sharedInstance] terminateAllApplications];

#pragma mark Exit retention- (BOOL)shouldDetainUser:(TMFMiniAppInfo *)app;

// Tap the capsule button to call up the panel/// If this method is not implemented, showActionSheetWithTitle:cancelButtonTitle:cancelAction:otherButtonTitleAndActions:dismissBlock:presentingViewController: will be called.// @param app Mini program information// @param cancelButtonTitle Cancel the title// @param cancelAction Cancel the operation// @param otherButtonTitleAndActions Other buttons and response operations// @param dismissBlock The operation that needs to be performed after the panel is closed (must be called to ensure the proper running of the feature).// @param parentVC The view controller that presents the panel- (void)showMoreButtonActionSheetWithApp:(TMFMiniAppInfo *)appcancelButtonTitle:(nullable NSString *)cancelButtonTitlecancelAction:(nullable dispatch_block_t)cancelActionotherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActionsdismissBlock:(nullable dispatch_block_t)dismissBlockparentVC:(UIViewController *)parentVC;

// In the superapp, you can customize the sharing channels and determine their display order. This feature is currently implemented in the ActionSheet triggered by tapping the More button or the button component (open-type="share").// 1. Default channels: QQ friends, Qzone, WeChat, and Moments (for specific types, see MAUIDelegateShareViewType). They are determined by the developer and the display order can only be changed within the superapp.// 2. Custom sharing channels: Customized in the superapp (set the type to MAUIDelegateShareViewTypeCustomizedShare, and when defining MAShareTarget, the value must be greater than 100. In the mini program page, onShareAppMessage will return the sharing content, which will be uniformly handled through shareMessageWithModel, allowing the superapp to process each ShareTarget individually.)// 3. Custom events: Customized in the superapp (set the type to MAUIDelegateShareViewTypeCustomizedAction).// The display order of the above three types of channels supports mixed arrangement- (NSArray<TMASheetItemInfo *> *)customizedConfigForShare;
- (NSArray<TMASheetItemInfo *> *)customizedConfigForShare {NSMutableArray *arrays = [[NSMutableArray alloc] init];TMASheetItemInfo *item1 = [[TMASheetItemInfo alloc] initWithTitle:@"More sharing" type:MAUIDelegateShareViewTypeCustomizedShare shareTarget:100 shareKey:@"my"];item1.icon = [UIImage imageNamed:@"icon_moreOperation_shareChat"];[arrays addObject:item1];TMASheetItemInfo *item2 = [[TMASheetItemInfo alloc] initWithTitle:@"click" type:MAUIDelegateShareViewTypeCustomizedAction action:^(TMASheetActionParams * _Nullable params) {NSLog(@"Tap");}];item2.icon = [UIImage imageNamed:@"icon_moreOperation_collect"];[arrays addObject:item2];return arrays;}

- (void)customizedConfigForMoreButtonActions:(NSMutableArray *)moreButtonTitleAndActions withApp:(TMFMiniAppInfo *)app{/*// Add a custom sharing channelTMASheetItemInfo *item = [[TMASheetItemInfo alloc] initWithTitle:@"Share" type:MAUIDelegateShareViewTypeCustomizedShare shareTarget:100 shareKey:@"my"];item.icon = [UIImage imageNamed:@"icon_moreOperation_shareChat"];[moreButtonTitleAndActions addObject:item];*//*// Delete the “Copy link” buttonNSMutableArray *newArrays = [[NSMutableArray alloc] initWithCapacity:moreButtonTitleAndActions.count];for (TMASheetItemInfo *item in moreButtonTitleAndActions) {if(item.type != MAUIDelegateShareViewTypeCopyLink) {[newArrays addObject:item];}}[moreButtonTitleAndActions removeAllObjects];[moreButtonTitleAndActions addObjectsFromArray:newArrays];*/}
Mini program API | TMFMiniAppSDKDelegate method |
wx.showLoading |
|
wx.hideLoading |
|
wx.showToast |
|
wx.hideToast |
|
wx.showActionSheet (actionSheetType = 0) |
|
wx.showActionSheet (actionSheetType = 1) |
|
wx.showModal |
|
/// Output the log/// @param level Log level. For more information, see PLTLogLevel./// @param msg Log message- (void)log:(MALogLevel)level msg:(NSString *)msg;
- (NSString *)getAppTheme{return @"dark";}


- (NSString *)getAppScheme{return @"tcsas";}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {if ([[TMFMiniAppSDKManager sharedInstance] handleOpenUrl:url]){return YES;}return YES;}
#import <TCMPPSDK/TCMPPSDK.h>@interface NativePluginTest : NSObject@end
#import "NativePluginTest.h"#import <TCMPPSDK/TCMPPSDK.h>@implementation NativePluginTestTMA_REGISTER_EXTENAL_JSPLUGIN;// Custom synchronous APITMAExternalJSAPI_IMP(testSync) {TMFMiniAppInfo *appInfo = context.tmfAppInfo;NSDictionary *data = params[@"data"];NSLog(@"************ invokeNativePlugin testSync,appId:%@,data is %@",appInfo.appId, data);TMAExternalJSPluginResult *pluginResult = [TMAExternalJSPluginResult new];pluginResult.result = @{};return pluginResult;}TMAExternalJSAPI_IMP(test) {TMFMiniAppInfo *appInfo = context.tmfAppInfo;NSDictionary *data = params[@"data"];NSLog(@"************ invokeNativePlugin test,appId:%@,data is %@",appInfo.appId, data);// Asynchronous processing, return the result to the mini program in the async callback//{// TMAExternalJSPluginResult *pluginResult = [TMAExternalJSPluginResult new];// pluginResult.result = @{@"result" : result.data};// [context doCallback:pluginResult];// }return nil;}@end
// Asynchronous API callvar opts = {api_name: 'test',success: function(res) {},fail: function(res) {},complete: function(res) {},data: { // Input parametersname : 'kka',age : 22}}wx.invokeNativePlugin(opts);// Synchronous API callvar opts = {api_name: 'testSync',sync:true}var rst = wx.invokeNativePlugin(opts);
{"extApi":[{"name": "test","sync": false,"params": {"data": ""}},{"name": "testSync","sync": true,"params": {"name": "","title": ""}}]}

[[TMFMiniAppSDKManager sharedInstance] setCustomApiConfigFile:[[NSBundle mainBundle] pathForResource:@"customapi-config" ofType:@"json"]];
// Asynchronous API callvar opts = {success: function(res) {},fail: function(res) {},complete: function(res) {},data: {name : 'kka',age : 22}}wx.test(opts);// Synchronous API callvar rst = testSync(opts);
#import "QMATestView.h"#import "TMAExternalJSPlugin.h"@interface QMATestView () <TMAExternalElementView>@end@implementation QMATestView {UILabel *_textLabel;UIButton *_clickButton;id<TMAExternalJSContextProtocol> _context;}TMARegisterExternalElement(maTestView);+ (UIView *)createWithParams:(NSDictionary *)params context:(id<TMAExternalJSContextProtocol>)context {QMATestView *testView = [[QMATestView alloc] initWithFrame:CGRectZero];NSDictionary *testViewParams = QQ_Dict_DictValue(params, @"params");[testView setText:QQ_Dict_StringValue(testViewParams, @"text")];testView->_context = context;return testView;}// Handle events from the mini program- (void)operateWithParams:(NSDictionary *)param context:(id<TMAExternalJSContextProtocol>)context {NSDictionary *data = QQ_Dict_DictValue(param, @"data");NSDictionary *params1 = QQ_Dict_DictValue(data, @"params1");NSInteger age = [QQ_Dict_NumberValue(params1, @"age") integerValue];NSString *name = QQ_Dict_StringValue(params1, @"name");qq_weakify(self);[MAUtils executeOnThread:[NSThread mainThread] block:^{qq_strongify(self);if (self) {self->_textLabel.text = [NSString stringWithFormat:@"name = %@ , age = %ld",name,(long)age];// Return the result to the mini programTMAExternalJSPluginResult *result = [TMAExternalJSPluginResult new];result.result = @{@"result":@"success"};[context doCallback:result];}}];}
_context = context;
- (void)onClickButton:(UIButton *)button {_textLabel.text = @"What do you want me to do";// Assemble data and send the eventNSString *data = [MAUtils JSONStringify:@{@"externalElementId":_elementId,@"type": @"elvisgao callback"}];[_context doSubscribe:kTMAOnExternalElementEvent data:data];}
<external-elementid="comp1"type="maTestView"_insert2WebLayerstyle="width: 200px;height: 100px;"bindexternalelementevent="handleEvent"></external-element>
{target,currentTarget,timeStamp,touches,detail, // Parameters passed by native}
this.ctx = wx.createExternalElementContext('comp1');
this.ctx.call({params1: {name: 'name1',age: 11},params2: {name: 'name2',age: 22},success: (e) => {console.log('====operate success=====', e)},fail: (e) => {console.log('====operate fail=====', e)},complete: (e) => {console.log('====operate complete=====', e)}})
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan