tencent cloud

Customizing Sharing Capabilities
Last updated:2026-01-29 00:28:08
Customizing Sharing Capabilities
Last updated: 2026-01-29 00:28:08

Default sharing channel configuration

You can customize the default sharing channels by overriding the defaultSharingChannels method.
API description:
// Default sharing channels after tapping the capsule button - includes MAShareTargetQQ, MAShareTargetQzone, MAShareTargetWXFriends, MAShareTargetWXMoment (the mini program configuration must be a subset of superapp)
- (NSArray<NSNumber *> *)defaultSharingChannels;
Example:
- (NSArray<NSNumber *> *)defaultSharingChannels{
return @[@(MAShareTargetQQ),@(MAShareTargetWXFriends),@(MAShareTargetWXMoment)];
}

Add custom share button

By overriding the customizedConfigForShare method, you can customize the sharing channels and determine their display order.
API description:

// 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;
Example:

- (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"];
item1.shareTarget = 10001;
[arrays addObject:item1];

TMASheetItemInfo *item2 = [[TMASheetItemInfo alloc] initWithTitle:@"click" type:MAUIDelegateShareViewTypeCustomizedAction action:^(TMASheetActionParams * _Nullable params) {
NSLog(@"click action triggered");
}];
item2.icon = [UIImage imageNamed:@"icon_moreOperation_collect"];
[arrays addObject:item2];
return arrays;

}
Here’s how it looks:

Here’s how the share channels look:

Note:
To enable the share button, set the open-type="share" attribute on the mini program’s button component.
By default, all custom share channels implemented via the superapp proxy API are displayed (including both MAUIDelegateShareViewTypeCustomizedShare and MAUIDelegateShareViewTypeCustomizedAction types), along with the default share channels.
In a mini program, you can specify the share channel using the button component’s share-mode attribute. The share-mode value corresponds to the shareKey property of the TMASheetItemInfo object. Once a share channel is specified, only the MAUIDelegateShareViewTypeCustomizedShare type of share channels within the superapp will be shown.

Mini program internal logic

Within the mini program, the onShareAppMessage event listens for users tapping share-type buttons and allows customization of the share content.

Sharing logic implementation

When the superapp receives the sharing data returned from the mini program, it triggers shareMessageWithModel to execute the final sharing action. Developers can handle the content to be shared based on shareTarget and other data, integrating with third-party sharing platforms.

/**
* @brief - Share API
* @param shareModel - Share model
* @param appInfo - Mini program info
* @param completionBlock - Callback
*/
- (void)shareMessageWithModel:(TMAShareModel *_Nonnull)shareModel
appInfo:(TMFMiniAppInfo *_Nonnull)appInfo
completionBlock:(nullable void(^)(NSError * _Nullable error))completionBlock;

Image sharing logic implementation

Superapp developers can also customize the share list shown by wx.showShareImageMenu via the customizedConfigForImageShare.
Share items of type MAUIDelegateShareViewTypeCustomizedShare are handled uniformly by the delegate API method shareMessageWithModel:appInfo:completionBlock.
Share items of type MAUIDelegateShareViewTypeCustomizedAction execute custom defined actions within the superapp.
Example:
- (NSArray<TMASheetItemInfo *> *)customizedConfigForImageShare {
TMASheetItemInfo *item = [[TMASheetItemInfo alloc] initWithTitle:@"Send to friend" type:MAUIDelegateShareViewTypeCustomizedShare shareTarget:200 shareKey:@"my"];
TMASheetItemInfo *item2 = [[TMASheetItemInfo alloc] initWithTitle:@"test" type:MAUIDelegateShareViewTypeCustomizedAction shareTarget:201];
item2.action = ^(TMASheetActionParams * _Nullable params0) {
NSLog(@"");
};
return @[item,item2];
}
Here’s how it looks:


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback