tencent cloud

Feedback

Customize mini program information API

Last updated: 2024-07-03 18:10:49

    Customizing user information in authorization pop-up box

    When a mini program requests user information, an authorization pop-up will appear. The host app can customize certain parts of this pop-up, including the profile image and username, as shown in the image below:
    
    
    
    You can achieve this customization by overriding the fetchAppUserInfoWithScope method.
    /**
     * @brief Fetch the profile photo and username from the SDK host platform based on the scope. The photo is returned as a UIView. The block must run on the main thread!!!
     - Pull the user avatar and nickname of the SDK host platform according to the scope. The avatar returns to UIView. The block must run on the main thread!!!
     */
    - (void)fetchAppUserInfoWithScope:(NSString *)scope block:(TMAAppFetchUserInfoBlock)block;
    Sample code:
    
    - (void)fetchAppUserInfoWithScope:(NSString *)scope block:(TMAAppFetchUserInfoBlock)block {
    if (block) {
    UIImage *defaultAvatar = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"avatar.png"]];
    UIImageView *avatarView = [[UIImageView alloc] initWithImage:defaultAvatar];
    TMAAppUserInfo *userInfo = [TMAAppUserInfo new];
    userInfo.avatarView = avatarView;
    userInfo.nickName = @"SunWukong";
    block(userInfo);
    }
    }

    Customizing the userAgent in mini program WebView

    Override the customUserAgent method to customize the user agent. Example code:
    
    - (NSString *)customUserAgent:(NSString *)defaultUserAgent;

    Customizing code scaning capability

    The mini program SDK provides a default scan implementation (refer to the extension library support - Scan), and also offers an API for users to customize the scan capability.
    // Scan the code to call the client's scan code module scancode - Scan the code to call the client's scan code module scancode
    // @param scanPrams Scan code parameter dictionary - scan code parameter dictionary
    // @param navigationController Calls vc from the page - calls vc from that page
    // @param completionHandler Callback result - callback result
    - (void)scanCode:(NSDictionary *)scanPrams
    navigationController:(UINavigationController *)navigationController
    completionHandler:(MACommonCallback)completionHandler;

    Monitoring mini program lifecycle

    Override the lifeCycleForApp method to monitor the mini program lifecycle.
    // Transparently transmit the application life cycle processing, and the business will process its own logic - Transparently transmit the application life cycle processing, and the business will process its own logic.
    // @param appInfo Mini program information - The mini program information
    // @param type Status - The state
    - (void)lifeCycleForApp:(TMFMiniAppInfo *)appInfo type:(TMAAppLifeCycleType)type;

    Customizing base library update strategy and monitoring

    Override the canUpdateJSBaseLib method to monitor the update information of the mini program's base library.
    // Base library update control - Basic library update control
    // @param libInfo Update information including version: version number, url: download address, md5: download file md5 - The update information including version: version number, url: download address, md5: download file md5
    // @return Whether to agree to update - Whether agree to update
    - (BOOL)canUpdateJSBaseLib:(NSDictionary *)libInfo;
    
    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