tencent cloud

Feedback

Customize Sharing Capability

Last updated: 2024-11-21 18:00:49

    Default Sharing Channels Configuration

    The default sharing channels can be customised by overriding the defaultSharingChannels method.
    API Description:
    // Default sharing channel after clicking capsule button - MAShareTargetQ, MAShareTargetQzone, MAShareTargetWXFriends, MAShareTargetWXMoment in MAShareTarget (must be a subset of the App for mini program configuration)
    // The default sharing channel after clicking the pill button - MAShareTarget (MAShareTargetQQ、MAShareTargetQzone、MAShareTargetWXFriends、MAShareTargetWXMoment)
    // (The configuration of the mini program must be a subset of the App)
    - (NSArray<NSNumber *> *)defaultSharingChannels;
    Sample code:
    - (NSArray<NSNumber *> *)defaultSharingChannels{
    return @[@(MAShareTargetQQ),@(MAShareTargetWXFriends),@(MAShareTargetWXMoment)];
    }

    Adding customised share buttons

    By overriding the customisedConfigForShare method, you can customize the sharing route and determine the display order.
    API description
    
    // The host App can customise the sharing channels and determine the display order, which is currently used in the ActionSheet called up by clicking the More button and the Button component (open-type="share").
    // 1. Default channels: QQ friends, Qzone, WeChat, Circle of Friends (see MAUIDelegateShareViewType), determined by the developer, the host app can only change the display order.
    // 2, custom sharing channels: host App custom (type fill MAUIDelegateShareViewTypeCustomizedShare, custom MAShareTarget, it is recommended to be greater than 100, in the mini program page onShareAppMessage back to share the content of the unified go) (shareMessageWithModel is handled separately by the host according to ShareTarget).
    // 3, custom event processing: host App custom (type fill MAUIDelegateShareViewTypeCustomizedAction).
    // The above three channels display order support mixed arrangement
    ///
    // The host app can customise the share path and determine the display order. Currently used in ActionSheets called by clicking the More button or button component (open-type="share").
    // 1. Default channels: QQ Friends, Qzone, WeChat, Moment (see MAUIDelegateShareViewType), determined by the developer, the host app can only change the display order.
    // 2. Custom sharing channels: host App custom (type fill in MAUIDelegateShareViewTypeCustomizedShare, custom MAShareTarget, it is recommended to be greater than 100, in the page of the mini program, onShareAppMessage to return to the content of the share, unified use) (shareMessageWithModel, the host according to ShareTarget are handled separately)
    // 3. Custom event handling: host app custom (type fill in MAUIDelegateShareViewTypeCustomizedAction)
    // The order in which the above three channels are displayed
    - (NSArray<TMASheetItemInfo *> *)customisedConfigForShare;
    Sample code:
    
    - (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 Sample code:");
    }];
    item2.icon = [UIImage imageNamed:@"icon_moreOperation_collect"];
    [arrays addObject:item2];
    return arrays;
    
    }
    The effect is as follows:
    

    Internal logic of the mini program

    The mini program internally listens for user clicks on the share class button via onShareAppMessage and customises the forwarded content.

    Share Logic Implementation

    After the host APP receives the sharing data returned from the mini program, it triggers shareMessageWithModel to execute the final sharing action, and the developer can process the content to be shared according to the shareTarget and other data by themselves, and docking to the three-party sharing platform.
    /**
    * @brief shareModel Shared Interface - Shared Interface
    * @param shareModel shareModel - shared model
    * @param appInfo mini program appinfo - Mini program appinfo
    * @param completionBlock Callback - Callbacks
    */
    - (void)shareMessageWithModel:(TMAShareModel *_Nonnull)shareModel
    appInfo:(TMFMiniAppInfo *_Nonnull)appInfo
    completionBlock:(nullable void(^)(NSError * _Nullable error))completionBlock;
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support