Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
accept," it indicates that the user has agreed to subscribe to the template message corresponding to the template ID, and the template is available.// tmplIds:Array of template IDs that need to be subscribedrequestSubscribeMessage(tmplIds) {wx.requestSubscribeMessage({tmplIds,success: (res) => {console.log('wx.requestSubscribeMessage success', res)const keysWithAccept = Object.entries(res).filter(([key, value]) => value === "accept").map(([key]) => key);if (keysWithAccept.length > 0) {// Send subscription messagethis.orderSubscribe(keysWithAccept)} else {wx.showModal({title: 'No available message templates',confirmText: 'Confirm',showCancel: false})}},fail: (res) => {console.log('wx.requestSubscribeMessage fail', res)wx.showModal({title: 'wx.requestSubscribeMessage fail',confirmText: 'Confirm',content: `${res.errMsg}【${res.errCode}】`,showCancel: false})}})}
this.orderSubscribe() API. The server should persist the successfully subscribed templates, subscription times, and subscriber (openid) information.name: {{name01.DATA}}amount: {{amount01.DATA}}journey: {{thing01.DATA}}date: {{date01.DATA}}
{"touser": "OPENID","template_id": "TEMPLATE_ID","page": "index","data": {"name01": {"value": "who "},"amount01": {"value": "$100"},"thing01": {"value": "from beijing to shanghai"} ,"date01": {"value": "2018-01-01"}}}




// Define an array variable jsonDatas to store the retrieved data, initialized to nilBLOCK_ARRAY jsonDatas = nil;// Call getMessage method of the singleton SubscriptionManager to retrieve message data// Parameters:// - token: The token for the logged-in user// - appId: The mini game key from the configuration file (tcmpp-ios-configurations.json or tcmpp-android-configurations.json)// Successful callback:// - message: The array of retrieved message data// Failed callback:// - error: Error information[SubscriptionManager.sharedInstance getMessage: UserInfo.sharedInstance.tokenappId: MiniAppSDKManager.sharedInstance.configAppKeysuccess:^(ARRAY message) {// Check if message is of array type; if not, return directlyif (![message isArray]) {return;}// Check if the message array is empty; if so, return directlyif ([message isEmpty]) {return;}// Assign the retrieved message data array to the jsonDatas variablejsonDatas = message;// Create a mutable array arrayDatas to store the parsed data modelsMUTABLE_ARRAY arrayDatas = [NSMutableArray array];// Iterate through the jsonDatas arrayfor (DICTIONARY json in jsonDatas) {// Parse each json data into a SubscribeInfoModel objectSubscribeInfoModel *model = [[SubscribeInfoModel alloc] initWithJsonDatas: json];// Add the model object to the arrayDatas array[arrayDatas addObject: model];}// Assign the arrayDatas array to the self.modelDatas propertyself.modelDatas = [NSArray arrayWithArray: arrayDatas];// Asynchronously execute the tableView's reloadData method on the main thread to refresh the table data[self.tableView performSelectorOnMainThread: @selector(reloadData)withObject: nilwaitUntilDone: YES];}failure:^(ERROR error) {// Handle the failure to retrieve message data; provide failure notifications based on business scenarios}];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{// Get the subscription model object corresponding to the tapped cardSubscribeInfoModel *model = self.modelDatas[indexPath.row];// Pass the parameters of the subscription model object and call the SDK's method to open the mini game[[TMFMiniAppSDKManager sharedInstance] startUpMiniAppWithAppID:model.MnpId verType:model.vertype scene:0 firstPage:model.Page paramsStr:nil parentVC:self completion:^(NSError * _Nullable error) {if(error) {// Opening failed; provide a notification based on the business scenarioreturn;}// Opening succeeded; provide a notification based on the business scenario}];}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback