# Delegate Methods

Some business logic in Mini-Programs is abstractly defined. These abstract business functions are exposed to the outside through interfaces, allowing external implementations to handle specific business logic.

# Overview

  • IAppletHandler: The earliest delegate, containing proxy methods for button open-type and more panels, etc. It will soon be deprecated.
  • IAppletProcessHandler: Delegate triggered by some processes within the Mini-Program
  • AppletLoadingCallback: Delegate for custom loading dialogs of Mini-Programs
  • AppletOpenCallback: Delegate when a Mini-Program finishes opening
  • CapsuleHandler: Delegate for capsule operations in Mini-Programs
  • IAppletLifecycleObserver: Delegate for Mini-Program lifecycle events
  • IAppletOpenTypeHandler: Delegate for open-type events of button components in Mini-Programs
  • IShareAppletHandler: Delegate when the Mini-Program share button is clicked
  • IAppJsonHandler: Delegate for obtaining the Mini-Program appJson
  • AboutAppletHandler: Delegate for customizing the "About" page of Mini-Programs
  • IUserInfoHandler: Delegate for asynchronously fetching user information
  • IUserProfileHandler: Delegate for asynchronous implementation of getUserProfile
  • ShareSDKDelegate: Delegate for sharing Mini-Programs externally
  • ShortcutHandler: Delegate for the "Add to Desktop" event in the more menu
  • IAuthRequestHandler: Pre-delegate for Mini-Program authorization pop-up triggers
  • IAuthResultHandler: Delegate for Mini-Program authorization results
  • IAuthInfoHandler: Delegate for customizing the title and prompts of the authorization pop-up
  • IScopeSettingHandler: Delegate for customizing the settings page
  • ScopeDialogCustomHandler: Delegate for customizing the content of the authorization pop-up
  • IScopeStatusChangeHandler: Delegate for changes in authorization status on the Mini-Program settings page
  • IFinWatermarkFactory: Delegate for implementing the watermark overlay on Mini-Program pages
  • IAppletConfigFactory: Delegate for special configurations for specific Mini-Programs
  • IPrivacyHandler: Delegate for customizing privacy agreement information
  • AppletWebViewLoadHandler: Supports Host-App control over whether WebView can load H5 links
  • AppletConfigHandler: Delegate for Mini-Program configuration
  • AppletGrayVersionHandler: Delegate for Mini-Program grayscale configuration
  • AppletInteractionHandler: Delegate for Mini-Program component interactions (e.g., image component, previewImage, previewMedia long press will trigger this delegate)
  • AppletHomeBackPressedHandler: Delegate for swipe back or virtual back button actions on the Mini-Program home page
  • AppletTraceHandler: Delegate for traceable configurations in Mini-Programs
  • AppletXComponentHandler: Delegate for custom native View support with same-layer rendering
  • ICustomScopeRequestHandler: Delegate for custom permission request pop-up interfaces
  • AppletWebViewURLRouterHandler: Delegate for WebView tag and H5 application page URL routing notifications in Mini-Programs
  • AppletBackPressedHandler: Delegate for intercepting system back button presses in Mini-Program pages
  • IEventReportHandler: Delegate for Mini-Program data reporting events

# 1. IAppletHandler

Supported app types

Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

Some abstract business logic is defined in IAppletHandler. Applications can pass an instance of IAppletHandler to the SDK by calling setAppletHandler from IAppletApiManager. When the business logic is triggered, the SDK will call back to the external implementation via corresponding methods in IAppletHandler, executing the specific business logic implemented externally.

/**
 * Abstract business callback interface for Mini-Programs. The SDK exposes these abstract businesses through interfaces, allowing external implementations to handle them.
 */
interface IAppletHandler {

    interface IAppletCallback {

        /**
         * Success callback
         */
        fun onSuccess(result: JSONObject? = null)

        /**
         * Failure callback
         */
        fun onFailure()

        /**
         * Cancel callback
         */
        fun onCancel()
    }

    /**
     * Share Mini-Program message
     *
     * @param appInfo Mini-Program information as a JSON string, including Mini-Program ID, name, icon, user ID, and shared content data.
     * [appInfo] format:
     * {
     *      "appTitle": "FinClip Mini-Program",
     *      "appAvatar": "https:\/\/www.finogeeks.club\/statics\/images\/swan_mini\/swan_logo.png",
     *      "appId": "5df36b3f687c5c00013e9fd1",
     *      "appType": "trial",
     *      "userId": "finogeeks",
     *      "params": {
     *           "title": "apt-test-tweet-API test published dynamic!@#$%^&*()",
     *           "desc": "Your service expert nearby",
     *           "imageUrl": "finfile:\/\/tmp_fc15edd8-2ff6-4c54-9ee9-fe5ee034033d1576550313667.png",
     *           "path": "pages\/tweet\/tweet-detail.html?fcid=%40staff_staff1%3A000000.finogeeks.com&timelineId=db0c2098-031e-41c4-b9c6-87a5bbcf681d&shareId=3dfa2f78-19fc-42fc-b3a9-4779a6dac654",
     *           "appInfo": {
     *               "weixin": {
     *                   "path": "\/studio\/pages\/tweet\/tweet-detail",
     *                   "query": {
     *                       "fcid": "@staff_staff1:000000.finogeeks.com",
     *                       "timelineId": "db0c2098-031e-41c4-b9c6-87a5bbcf681d"
     *                    }
     *               }
     *           }
     *       }
     * }
     * Explanation of fields in [appInfo]:
     * appId Mini-Program ID
     * appTitle Mini-Program name
     * appAvatar Mini-Program avatar
     * appType Mini-Program type, where trial indicates trial version, temporary indicates temporary version, review indicates review version, release indicates online version, and development indicates development version
     * userId User ID
     * params Other parameters passed through by the Mini-Program itself
     *     
     * @param bitmap Mini-Program cover image. If [appInfo].params.imageUrl field is an http or https link, then the Mini-Program cover image
     * takes the image corresponding to [appInfo].params.imageUrl; otherwise, it takes [bitmap].
     */
    fun shareAppMessage(appInfo: String, bitmap: Bitmap?, callback: IAppletCallback)

    /**
     * Get user information
     *
     * @return User information [Map]
     */
    fun getUserInfo(): Map<String, String>
  
  	/**
     * Get user phone number
     * Returns information in JSON format via callback, typically formatted as follows:
     * {"phone": "xxxxxxxxxxx"}
     */
  	override fun getPhoneNumber(callback: IAppletHandler.IAppletCallback) {
        callback.onSuccess(JSONObject().put("phone", "xxxxxxxxxxx"))
    }

  	/**
     * Event when returning from Mini-Program page to Host-App page, implemented by the Host-App;
     * @return Return true if the event is handled correctly, otherwise return false.
     */
    override fun launchApp(appParameter: String?): Boolean {
        return false
    }

  	/**
     * Open "Feedback" page, implemented by the Host-App;
     * @return Return true if the Host-App handles this event, otherwise return false and open the default feedback page.
     */
    override fun feedback(bundle: Bundle): Boolean {
        return false
    }

  	/**
     * Get user avatar, return information via callback, passed through to the Mini-Program by the SDK
     */
    override fun chooseAvatar(callback: IAppletHandler.IAppletCallback) {
        callback.onFailure()
    }

  	/**
     * Open customer service chat, implemented by the Host-App
     * @param json Data passed from the Mini-Program to the Host-App
     * @return Return true if the session opens successfully, otherwise return false
     */
    override fun contact(json: JSONObject): Boolean {
        return false
    }
    
     /**
     * Default returns true
     */
    fun getJSSDKConfig(json: JSONObject, callback: IAppletCallback)
    
    /**
     * Get registered "More" menu items
     *
     * @param appId Mini-Program ID
     * @return Registered "More" menu items
     */
    fun getRegisteredMoreMenuItems(appId: String): List<MoreMenuItem>?

    /**
     * Registered "More" menu item clicked
     *
     * @param appId Mini-Program ID
     * @param path Mini-Program page path
     * @param menuItemId ID of the clicked menu item
     * @param appInfo Mini-Program information as a JSON string, including Mini-Program ID, name, icon, user ID, and shared content data.
     * [appInfo] format:
     * {
     *      "appTitle": "FinClip Mini-Program",
     *      "appAvatar": "https:\/\/www.finogeeks.club\/statics\/images\/swan_mini\/swan_logo.png",
     *      "appId": "5df36b3f687c5c00013e9fd1",
     *      "appType": "trial",     
     *      "userId": "finogeeks",
     *      "params": {
     *           "title": "apt-test-tweet-API test published dynamic!@#$%^&*()",
     *           "desc": "Your service expert nearby",
     *           "imageUrl": "finfile:\/\/tmp_fc15edd8-2ff6-4c54-9ee9-fe5ee034033d1576550313667.png",
     *           "path": "pages\/tweet\/tweet-detail.html?fcid=%40staff_staff1%3A000000.finogeeks.com&timelineId=db0c2098-031e-41c4-b9c6-87a5bbcf681d&shareId=3dfa2f78-19fc-42fc-b3a9-4779a6dac654",
     *           "appInfo": {
     *               "weixin": {
     *                   "path": "\/studio\/pages\/tweet\/tweet-detail",
     *                   "query": {
     *                       "fcid": "@staff_staff1:000000.finogeeks.com",
     *                       "timelineId": "db0c2098-031e-41c4-b9c6-87a5bbcf681d"
     *                    }
     *               }
     *           }
     *       }
     * }
     * Explanation of fields in [appInfo]:
     * appId Mini-Program ID
     * appTitle Mini-Program name
     * appAvatar Mini-Program avatar
     * appType Mini-Program type, where trial indicates trial version, temporary indicates temporary version, review indicates review version, release indicates online version, and development indicates development version
     * userId User ID
     * params Other parameters passed through by the Mini-Program itself
     *
     * @param bitmap Mini-Program cover image. If [appInfo].params.imageUrl field is an http or https link, then the Mini-Program cover image
     * takes the image corresponding to [appInfo].params.imageUrl; otherwise, it takes [bitmap].
     */
    fun onRegisteredMoreMenuItemClicked(appId: String, path: String, menuItemId: String, appInfo: String?, bitmap: Bitmap?, callback: IAppletCallback)
    
    /**
     * Get grayscale release configuration parameters
     *
     * @param appId Mini-Program ID
     * @return Grayscale release configuration parameters
     */
    fun getGrayAppletVersionConfigs(appId: String): List<GrayAppletVersionConfig>?
    
    /**
     * "Close" button in Mini-Program navigation bar clicked
     *
     * @param appId Mini-Program ID
     */
    fun onNavigationBarCloseButtonClicked(appId: String)
}

# API

/**
 * Set the implementation class of [IAppletHandler]
 *
 * @param appletHandler Implementation class of [IAppletHandler]
 */
fun setAppletHandler(appletHandler: IAppletHandler)

# Usage Example

    Note

    • The FinAppClient class must be used in the main process.
    • For asynchronous callback methods (parameters with callback), ensure that the callback is invoked regardless of whether the business logic succeeds or fails. Otherwise, the Mini-Program side will not receive the invocation result.

    # 2. IAppletProcessHandler

    Supported App Types

    Mini-Program ✅ Mini-Game ✅ H5 Application ✅

    Some proxies triggered in the Mini-Program process.

    onNavigationBarMoreButtonClicked (deprecated, please use CapsuleHandler.onMoreButtonClick() instead), used to intercept and handle the click event of the "More" button in the Mini-Program navigation bar. When the proxy method returns true, the SDK will not display the more panel, and a custom implementation of the more panel is required.

    interface IAppletProcessHandler {
    
        /**
         * Triggered when the "More" button in the Mini-Program navigation bar is clicked.
         *
         * @param appId Mini-Program ID
         * @return Return `true` to handle the button click event yourself, without executing the default action (popup menu). Return `false` to execute the default action.
         */
        @Deprecated("Use CapsuleHandler.onMoreButtonClick() instead.")
        fun onNavigationBarMoreButtonClicked(context: Context, appId: String): Boolean
    }
    

    Example Code

      # 3 AppletLoadingCallback

      Supported App Types

      Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

      Note

      • The FinAppProcessClient class must be used in the Mini-Program process. Use the FinAppClient.INSTANCE.isFinAppProcess() method to determine if it is in the Mini-Program process.

      • The proxy methods in AppletLoadingCallback will execute in the Mini-Program process.

      The Host-App can customize the content of the Mini-Program loading page. Applicable scenarios: Each time the Host-App launches a Mini-Program, it adds a popup prompt to enter the internal third-party application or adds privacy agreements, etc.

      The SDK determines whether to trigger the display of custom content on the loading page based on whether custom views are needed according to the proxy methods. When displaying custom content, the Host-App needs to call onComplete in the callback at an appropriate time for the Mini-Program to continue execution.

      For example: Each time entering the Mini-Program, a popup is displayed on the loading page indicating that you are about to enter a third-party application, with "Allow" and "Reject" buttons. If "Allow" is clicked, call onComplete() in the callback; if "Reject" is clicked, close the Mini-Program.

      interface AppletLoadingCallback {
      
          /**
           * @param finAppInfo Mini-Program information
           * Determines whether to display custom content on the loading page based on the return value.
           */
          fun shouldShowCustomContent(finAppInfo: FinAppInfo): Boolean
      
          /**
           * Interface for displaying custom UI
           * @param finAppInfo Mini-Program information
           * @param activity Activity used to load the current custom page
           */
          fun showCustomContent(
              finAppInfo: FinAppInfo,
              activity: Activity,
              callback: AppletCustomContentHandler
          ) {
          }
      
      }
      

      Code Example:

      if (FinAppClient.isFinAppProcess(application)) {
        FinAppProcessClient.appletLoadingCallback =
          object : FinAppProcessClient.AppletLoadingCallback {
            override fun showCustomContent(
              finAppInfo: FinAppInfo,
              activity: Activity,
              handler: FinAppProcessClient.AppletCustomContentHandler
            ) {
              // Use activity to host the current custom page
              val builder: AlertDialog.Builder = AlertDialog.Builder(activity)
              // If not continuing to load, call `handler.onComplete` and set the `resume` parameter to `false`
              builder.setNegativeButton(R.string.cancel) { dialogInterface: DialogInterface, i: Int ->
                handler.onComplete(finAppInfo.appId, false, activity)
              }
              // If continuing to load, call `handler.onComplete` and set the `resume` parameter to `true`
              builder.setPositiveButton(R.string.confirm) { dialogInterface: DialogInterface, i: Int ->
                handler.onComplete(finAppInfo.appId, true, activity)
              }
              builder.setMessage("appId : ${finAppInfo.appId}  appTitle : ${finAppInfo.appTitle}")
              builder.create().show();
            }
      
            override fun shouldShowCustomContent(finAppInfo: FinAppInfo): Boolean {
              return true;
            }
          }
      }
      

      # 4. AppletOpenCallback

      Supported App Types

      Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

      Proxy for when the Mini-Program has finished opening.

      interface AppletOpenCallback {
          // Proxy method for when the Mini-Program has finished opening
          fun onAppletOpen(activity: Activity, appId: String, finAppInfo: FinAppInfo)
      }
      

      Code Example

        Note

        • The FinAppProcessClient class must be used in the Mini-Program process.

          Use the FinAppClient.INSTANCE.isFinAppProcess() method to determine if it is in the Mini-Program process.

        • Methods of the IAppletProcessHandler interface execute in the Mini-Program process.

        # 5. CapsuleHandler

        Supported App Types

        Mini-Program ✅ Mini-Game ✅ H5 Application ✅

        Added in version 2.42.3. Used to intercept and handle Mini-Program capsule button click events.

        /**
         * A proxy class for the Host-App to take over capsule operations
         */
        open class CapsuleHandler {
        
          class MoreButtonClickHandler {
            /**
             * Show/Hide the default more menu.
             * (Default logic when clicking the capsule "More" button)
             */
            fun changeDefaultMoreMenuVisibility()
          }
        
          class CloseButtonClickHandler {
            /**
             * Close the Mini-Program.
             * (Default logic when clicking the capsule "Close" button)
             */
            fun closeApplet()
          }
        
          /**
           * Triggered when the "More" button in the Mini-Program capsule is clicked
           *
           * @param context Mini-Program Context
           * @param appId Mini-Program ID
           */
          open fun onMoreButtonClick(context: Context, appId: String, handler: MoreButtonClickHandler)
        
          /**
           * Triggered when the "Close" button in the Mini-Program capsule is clicked
           *
           * @param context Mini-Program Context
           * @param appId Mini-Program ID
           */
          open fun onCloseButtonClick(context: Context, appId: String, handler: CloseButtonClickHandler)
          
          /**
             * Get registered "More" menu items
             *
             * @param appId Mini-Program ID
             * @return Registered "More" menu items
             */
            open fun getRegisteredMoreMenuItems(context: Context, appId: String): List<MoreMenuItem>? {
                return null
            }
        
            /**
             * Triggered when a registered "More" menu item is clicked
             *
             * @param appId Mini-Program ID
             * @param path Mini-Program page path
             * @param menuItemId ID of the clicked menu item
             * @param appInfo Mini-Program information, which is a JSON string containing Mini-Program ID, name, icon, user ID, and forwarded data content, etc.
             * The format of [appInfo] is as follows:
             * {
             *      "appTitle": "FinClip Mini-Program",
             *      "appAvatar": "https:\/\/www.finogeeks.club\/statics\/images\/swan_mini\/swan_logo.png",
             *      "appId": "5df36b3f687c5c00013e9fd1",
             *      "appType": "trial",
             *      "userId": "finogeeks",
             *      "params": {
             *           "title": "apt-test-tweet-API test published dynamic!@#¥%……&*(",
             *           "desc": "Your service expert nearby",
             *           "imageUrl": "finfile:\/\/tmp_fc15edd8-2ff6-4c54-9ee9-fe5ee034033d1576550313667.png",
             *           "path": "pages\/tweet\/tweet-detail.html?fcid=%40staff_staff1%3A000000.finogeeks.com&timelineId=db0c2098-031e-41c4-b9c6-87a5bbcf681d&shareId=3dfa2f78-19fc-42fc-b3a9-4779a6dac654",
             *           "appInfo": {
             *               "weixin": {
             *                   "path": "\/studio\/pages\/tweet\/tweet-detail",
             *                   "query": {
             *                       "fcid": "@staff_staff1:000000.finogeeks.com",
             *                       "timelineId": "db0c2098-031e-41c4-b9c6-87a5bbcf681d"
             *                    }
             *               }
             *           }
             *       }
             * }
             * Description of fields in [appInfo]:
             * appId Mini-Program ID
             * appTitle Mini-Program name
             * appAvatar Mini-Program avatar
             * appType Mini-Program type, where trial indicates trial version, temporary indicates temporary version, review indicates review version, release indicates online version, and development indicates development version
             * userId User ID
             * params Other parameters passed through by the Mini-Program itself
             *
             * @param bitmap Mini-Program cover image. If the [appInfo].params.imageUrl field is an HTTP or HTTPS link address, the Mini-Program cover image takes the image corresponding to [appInfo].params.imageUrl; otherwise, the Mini-Program cover image takes [bitmap].
             * @param callback Callback for forwarding Mini-Program results.
             */
             open fun onRegisteredMoreMenuItemClicked(
                context: Context,
                appId: String,
                path: String,
                menuItemId: String,
                appInfo: String?,
                bitmap: Bitmap?,
                callback: IAppletHandler.IAppletCallback) {
        
             }
        
        }
        

        onMoreButtonClick intercepts and handles the capsule "More" button click event. Custom more panels can be implemented.

        Code Example

          onCloseButtonClick intercepts and handles the capsule "Close" button click event.

          Code Example

            Delegate for custom menus in Mini-Programs and handling clicks on custom menus.

            Code Example

              # 6. IAppletLifecycleObserver

              Supported App Types

              Mini-Program ✅ Mini-Game ✅ H5 Application ✅

              If the Host-App needs to monitor the lifecycle of a Mini-Program, it can call the setAppletLifecycleObserver interface of IAppletApiManager to pass an instance of IAppletLifecycleObserver to the SDK. When the lifecycle of the Mini-Program changes, the SDK will notify the external system through corresponding methods in IAppletLifecycleCallback.

              /**
               * New interface for Mini-Program lifecycle callbacks
               */
              interface IAppletLifecycleObserver {
              
                /**
                 * Event when the Mini-Program has finished opening
                 * 
                 * At this point, the service layer has been fully loaded and communication with the Base Library is possible;
                 * This event will only be triggered once during the entire lifecycle;
                 * 
                 * @param appId Mini-Program ID
                 */
                fun onOpen(appId: String)
              
                /**
                 * Event when the Mini-Program is closed
                 * 
                 * All APIs that trigger Mini-Program closure will invoke this callback;
                 * Closing the Mini-Program does not necessarily mean the Mini-Program's Activity is destroyed;
                 * In non-single task stack scenarios, it simply moves the Mini-Program Activity task stack to the background;
                 * 
                 * @param appId Mini-Program ID
                 */
                fun onClose(appId: String)
              
                /**
                 * Event when the Mini-Program initialization is complete
                 * 
                 * At this point, the service layer has been fully loaded and communication with the Base Library is possible;
                 * This event will only be triggered once during the entire lifecycle;
                 * 
                 * @param appId Mini-Program ID
                 */
                fun onInitCompletion(appId: String)
              
                /**
                 * Event when the Mini-Program enters the active state
                 * 
                 * 1. Cold start, starting to load the Mini-Program's page;
                 * 2. Hot start, after the Mini-Program's Activity onResume (provided the service layer has been loaded);
                 * 
                 * @param appId Mini-Program ID
                 */
                fun onActive(appId: String)
              
                /**
                 * Event when the Mini-Program enters the inactive state
                 * 
                 * After the Mini-Program's Activity onPause (provided the service layer has been loaded);
                 * 
                 * @param appId Mini-Program ID
                 */
                fun onInActive(appId: String)
              
                /**
                 * Event when the Mini-Program encounters an error
                 * 
                 * Any error will trigger this callback;
                 * 
                 * @param appId Mini-Program ID
                 * @param errorMsg Error message
                 */
                fun onOpenFailure(appId: String, errorMsg: String)
              
                /**
                 * Event when the Mini-Program is destroyed
                 * 
                 * After the Mini-Program's Activity onDestroy;
                 * The Mini-Program is truly closed;
                 * 
                 * @param appId Mini-Program ID
                 */
                fun onDestroy(appId: String)
              }
              
              /**
               * Set [IAppletLifecycleObserver]
               *
               * @param appletLifecycleObserver [IAppletLifecycleObserver] object
               */
              fun setAppletLifecycleObserver(appletLifecycleObserver: IAppletLifecycleObserver)
              

              Example code:

                # 7. IAppletOpenTypeHandler

                Supported App Types

                Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                Starting from version 2.37.13, this is a delegate specifically extracted from IAppletHandler for handling open-type events, including getPhoneNumber, chooseAvatar, launchApp, contact, shareAppMessage, and feedback.

                /**
                 * Extract methods related to open-type from [IAppletHandler] for separate handling.
                 *
                 * If [IAppletOpenTypeHandler] is set, the methods related to open-type in [IAppletHandler] will not respond.
                 */
                interface IAppletOpenTypeHandler {
                    /**
                     * Get phone number
                     */
                    fun getPhoneNumber(callback: IAppletHandler.IAppletCallback)
                
                    /**
                     * Choose avatar
                     */
                    fun chooseAvatar(callback: IAppletHandler.IAppletCallback)
                
                    /**
                     * Return from Mini-Program to the main Host-App
                     */
                    fun launchApp(appParameter: String?): Boolean
                
                    fun contact(json: JSONObject): Boolean
                
                    /**
                     * Forward Mini-Program
                     *
                     * @param appInfo Mini-Program information, which is a JSON string containing Mini-Program ID, name, icon, user ID, and forwarded data content.
                     * The format of [appInfo] is as follows:
                     * {
                     *      "appTitle": "FinClip Mini-Program",
                     *      "appAvatar": "https:\/\/www.finogeeks.club\/statics\/images\/swan_mini\/swan_logo.png",
                     *      "appId": "5df36b3f687c5c00013e9fd1",
                     *      "appType": "trial",
                     *      "userId": "finogeeks",
                     *      "params": {
                     *           "title": "apt-test-tweet-API test published dynamic!@#¥%……&*(",
                     *           "desc": "Your service expert nearby",
                     *           "imageUrl": "finfile:\/\/tmp_fc15edd8-2ff6-4c54-9ee9-fe5ee034033d1576550313667.png",
                     *           "path": "pages\/tweet\/tweet-detail.html?fcid=%40staff_staff1%3A000000.finogeeks.com&timelineId=db0c2098-031e-41c4-b9c6-87a5bbcf681d&shareId=3dfa2f78-19fc-42fc-b3a9-4779a6dac654",
                     *           "appInfo": {
                     *               "weixin": {
                     *                   "path": "\/studio\/pages\/tweet\/tweet-detail",
                     *                   "query": {
                     *                       "fcid": "@staff_staff1:000000.finogeeks.com",
                     *                       "timelineId": "db0c2098-031e-41c4-b9c6-87a5bbcf681d"
                     *                    }
                     *               }
                     *           }
                     *       }
                     * }
                     * Explanation of fields in [appInfo]:
                     * appId Mini-Program ID
                     * appTitle Mini-Program name
                     * appAvatar Mini-Program avatar
                     * appType Mini-Program type, where trial indicates trial version, temporary indicates temporary version, review indicates review version, release indicates online version, and development indicates development version
                     * userId User ID
                     * params Other parameters passed through by the Mini-Program itself
                     *
                     * @param bitmap Mini-Program cover image. If the [appInfo].params.imageUrl field is an HTTP or HTTPS link, the Mini-Program cover image will be taken from [appInfo].params.imageUrl; otherwise, it will be taken from [bitmap].
                     * @param callback Callback for the result of forwarding the Mini-Program.
                     */
                    fun shareAppMessage(appInfo: String, bitmap: Bitmap?, callback: IAppletHandler.IAppletCallback)
                
                    /**
                     * Open Host-App user feedback
                     */
                    fun feedback(bundle: Bundle): Boolean
                }
                

                Example code:

                  Note

                  • The FinAppClient class must be used in the main process.

                  • Setting IAppletOpenTypeHandler will override the implementation of the above open-type methods in IAppletHandler.

                  • If the WeChat Extension SDK (WeChatSDK) is integrated, do not use this interface class but instead use:

                    WeChatOpenTypeClient.instance.iWeChatOpenTypeHandler = MyWeChatAppletOpenTypeHandler()
                    

                  # 8. IShareAppletHandler

                  Supported App Types

                  Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                  Starting from version 2.39.11, a "Share" button will be added to the Mini-Program's more menu. You can rely on ShareSDK and perform simple configuration to implement the Mini-Program sharing feature, or you can implement the IShareAppletHandler interface to achieve the corresponding functionality.

                  Note

                  The implementation class of IShareAppletHandler will be instantiated via reflection during Mini-Program runtime, so please ensure a parameterless constructor and avoid directly accessing variables within the main process, otherwise exceptions may occur.

                  interface IShareAppletHandler {
                      fun onShareApplet(context: Context, appInfo: FinAppInfo, appletPagePath: String)
                  }
                  

                  Example code:

                    And set it during SDK initialization.

                    Code example:

                      # 9. IAppJsonHandler

                      Supported App Types

                      Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                      Starting from version 2.40.1, the Host-App can retrieve the app.json content of the launched Mini-Program.

                      Note

                      The implementation class of IAppJsonHandler will be instantiated via reflection during Mini-Program runtime, so please ensure a parameterless constructor and avoid directly accessing variables within the main process, otherwise exceptions may occur.

                      The content returned in this delegate method is the processed content of app.json and page.json after being handled by the compilation library.

                      interface IAppJsonHandler {
                          fun onAppJsonInit(appInfo: FinAppInfo, appJson: String)
                      }
                      

                      Code Example:

                        Set during SDK initialization.

                        Example Code:

                          # 10. AboutAppletHandler

                          Supported App Types

                          Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                          Starting from version 2.40.5, it supports the Host-App to customize the about page of the Mini-Program. The host project inherits the AboutAppletHandler class and jumps to the customized about page in the goToAboutPage method.

                          /**
                           * Open a custom about Mini-Program page.
                           * If the custom about Mini-Program page is an Activity, it is recommended to set 
                           * android:multiprocess="true" when declaring the Activity in AndroidManifest.xml, 
                           * allowing the Activity to run in the Mini-Program process,
                           * so that the Activity can terminate with the Mini-Program process (e.g., when the Mini-Program calls finishRunningApplet).
                           *
                           * @param appInfo Mini-Program information
                           *
                           * @return true to open the custom about Mini-Program page, false to open the default about Mini-Program page
                           */
                          open fun goToAboutPage(context: Context, appInfo: FinAppInfo): Boolean {
                              return false
                          }
                          

                          Example Code:

                            # 11. IUserInfoHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            Previous IAppletOpenTypeHandler and IAppletHandler delegate methods required the Host-App to synchronously obtain user information and return it. However, there may be scenarios where the Host-App can only asynchronously obtain the Host-App's user information, so we have added this delegate.

                            Note

                            • The delegate needs to be set after the SDK has been successfully initialized in the main process.
                            • After implementing this delegate, the getUserInfo methods in IAppletHandler and IAppletOpenTypeHandler that synchronously return results will no longer be triggered.
                            • Events in this delegate will be triggered in the main process.
                            interface IUserInfoHandler {
                            
                                fun getUserInfo(callback: IAppletHandler.IAppletCallback)
                            }
                            

                            Example Code:

                            public class MyUserInfoHandler extends IUserInfoHandler {
                                @Override
                                public void getUserInfo(@NotNull IAppletHandler.IAppletCallback callback) {
                                    try {
                                        JSONObject jsonObj = new JSONObject();
                                        jsonObj.put("nickname", "test_nickname");
                                        jsonObj.put("avatarUrl", "test_avatarUrl");
                                        callback.onSuccess(jsonObj);
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                        callback.onFailure();
                                    }
                                }
                            }
                            
                            MyUserInfoHandler userInfoHandler = new MyUserInfoHandler();
                            FinAppClient.INSTANCE.getAppletApiManager().setUserInfoHandler(userInfoHandler);
                            

                            # 12. IUserProfileHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            When the Mini-Program calls the getUserProfile interface, this delegate will be triggered, and the Host-App can implement this delegate method.

                            Note

                            • This implementation class may depend on the runtime status of the Mini-Program; different Mini-Programs may have different instances of this implementation class, so do not store variable values in this class for use, otherwise null values may occur.
                            • This implementation class will be instantiated via reflection during the Mini-Program runtime, so please maintain a parameterless constructor.
                            • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process, so do not directly access variables in the main process. (Starting from version 2.41.5, it will always run in the main process.)
                            • The context in the method is ApplicationContext, so do not use it directly to start Activity or similar operations.
                            • If you need to implement the getUserProfile method, do not use the custom API approach but instead implement the delegate class approach.
                            interface IUserProfileHandler {
                                fun getUserProfileWithAppletInfo(
                                    context: Context,
                                    finAppInfo: FinAppInfo,
                                    callback: UserProfileCallback
                                )
                            
                                interface UserProfileCallback {
                                    fun onSuccess(result: JSONObject?)
                            
                                    fun onError(msg: String?)
                                }
                            }
                            
                            1. Implement Delegate Method

                            Implement the IUserProfileHandler interface and complete the logic for obtaining UserProfile in getUserProfileWithAppletInfo.

                            Example as follows:

                            public class MyUserProfileHandler implements IUserProfileHandler {
                                @Override
                                public void getUserProfileWithAppletInfo(@NotNull Context context,
                                                                         @NotNull FinAppInfo finAppInfo,
                                                                         @NotNull IUserProfileHandler.UserProfileCallback callback) {
                                    try {
                                        JSONObject jsonObj = new JSONObject();
                                        jsonObj.put("nickname", "test_nickname");
                                        jsonObj.put("avatarUrl", "test_avatarUrl");
                                        callback.onSuccess(jsonObj);
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                        callback.onError(null);
                                    }
                                }
                            }
                            
                            1. Set the Delegate

                            Inject the implementation class during SDK initialization:

                            val config = FinAppConfig.Builder()
                                // Other configurations omitted
                                .setGetUserProfileHandlerClass(MyUserProfileHandler::class.java)
                                .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            # 13. ShareSDKDelegate

                            Supported App Types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            Starting from version 2.40.11, ShareSDK supports customizing the landing page link for sharing and the APK download address in the shared link.

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as it may lead to null values or similar issues.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime, so ensure a parameterless constructor is available.
                            1. Implement the delegate methods

                            Inherit the ShareSDKDelegate class and override its methods as needed.

                            Code example:

                            public class MyShareDelegate extends ShareSDKDelegate {
                                @Override
                                public void onCustomShareUrl(@NonNull Context context, 
                                                             @NonNull FinAppInfo finAppInfo, 
                                                             @NonNull FinCallback<String> callback) {
                                    // Customize the landing page link for sharing
                                    callback.onSuccess("https://example.com/share/path");
                                }
                            
                                @Override
                                public void onCustomAppDownloadLink(@NonNull Context context, 
                                                                    @NonNull FinAppInfo finAppInfo, 
                                                                    @NonNull FinCallback<String> callback) {
                                    // Customize the APK download address in the shared link
                                    callback.onSuccess("https://example.com/download/app.apk");
                                }
                            }
                            
                            1. Set the implementation class of the delegate

                            Set this within the [Mini-Program process].

                            Code example:

                            public class MyApplication extends Application {
                            
                                @Override
                                public void onCreate() {
                                    super.onCreate();
                                    if (FinAppClient.INSTANCE.isFinAppProcess(this)) {
                                        // Initialize the Mini-Program process
                                        FinShareSDK.setShareSdkDelegateClass(MyShareDelegate.class);
                                    } else {
                                        // Other initializations for the main process
                                    }
                                }
                            }
                            

                            # 14. ShortcutHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            Starting from version 2.41.5, customization of the "Add to Desktop" button event in the extended menu is supported.

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as it may lead to null values or similar issues.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime, so ensure a parameterless constructor is available.
                            • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process, so avoid directly accessing variables in the main process.
                            open class ShortcutHandler {
                            
                                open fun addToDesktop(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    appletCurrentPath: String
                                ) {
                            
                                }
                            }
                            
                            1. Implement the delegate method in ShortcutHandler

                            Inherit the ShortcutHandler class and override the addToDesktop method.

                            Code example:

                            class MyShortcutHandler : ShortcutHandler() {
                                override fun addToDesktop(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    appletCurrentPath: String
                                ) {
                                    Toast.makeText(
                                        context,
                                        "${appInfo.appTitle}: $appletCurrentPath",
                                        Toast.LENGTH_LONG
                                    ).show()
                                }
                            }
                            
                            1. Set the implementation class of the delegate

                            Inject the implementation class during SDK initialization:

                            val config = FinAppConfig.Builder()
                                // Other configurations omitted
                                .setShortcutHandlerClass(MyShortcutHandler::class.java)
                                .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            # 15. IAuthRequestHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game ✅ H5 Application 🚫

                            Starting from version 2.40.3, Host-Apps can perform pre-processing for permission requests within Mini-Programs. Before triggering the permission dialog logic in the Mini-Program, this delegate will be triggered first, allowing the Host-App to decide whether to allow the Mini-Program to request the permission.

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as it may lead to null values or similar issues.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime, so ensure a parameterless constructor is available.
                            • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process, so avoid directly accessing variables in the main process.
                            /**
                             * Delegate class used by the Host-App for pre-processing scope requests or system permission requests
                             */
                            interface IAuthRequestHandler {
                                fun onAuthRequest(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    auth: AuthEnum,
                                    callback: IAuthRequestCallback
                                )
                            
                                interface IAuthRequestCallback {
                                    fun allowAuthRequest(preAllow: Boolean)
                                }
                            }
                            
                            1. The Host-App implements the IAuthRequestHandler interface and handles the pre-request for permissions in the onAuthRequest method.

                            Example code:

                            class AuthRequestHandler : IAuthRequestHandler {
                            
                                override fun onAuthRequest(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    auth: AuthEnum,
                                    callback: IAuthRequestHandler.IAuthRequestCallback
                                ) {
                                    AlertDialog.Builder(context)
                                        .setTitle("Host-App Pre-processing Permission Request")
                                        .setMessage("Permission: $auth")
                                        .setPositiveButton("Allow") { dialog, which ->
                                            callback.allowAuthRequest(true)
                                        }
                                        .setNegativeButton("Deny") { dialog, which ->
                                            callback.allowAuthRequest(false)
                                        }
                                        .setCancelable(false)
                                        .show()
                                }
                            }
                            

                            Parameter description:

                            Parameter Name Description
                            context Context object
                            appInfo Information about the Mini-Program
                            auth Requested permission
                            callback Callback for the pre-request result

                            Description of AuthEnum:

                            An enumeration class for permissions, without distinguishing between Mini-Program permissions and system permissions, but rather describing specific permission behaviors. Currently supported permissions are as follows:

                            Enum Class Description
                            AUTH_USERINFO User Info
                            AUTH_USER_LOCATION Location
                            AUTH_RECORD Recording
                            AUTH_READ_EXTERNAL_STORAGE Read Permission
                            AUTH_WRITE_EXTERNAL_STORAGE Write Permission
                            AUTH_CAMERA Camera
                            AUTH_BLUETOOTH Bluetooth
                            AUTH_CONTACT Contacts
                            AUTH_PHONE_NUMBER Phone Number
                            1. Inject the implementation class during SDK initialization
                            val config = FinAppConfig.Builder()
                              // Other configurations omitted
                              .setAuthRequestHandlerClass(AuthRequestHandler::class.java)
                              .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            # 16. IAuthResultHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game ✅ H5 Application 🚫

                            Starting from version 2.40.3, Host-Apps can receive the results of permission requests within Mini-Programs. (Currently, only APIs related to the Core SDK and Extension SDK are supported.)

                            /**
                             * Delegate class used by the Host-App for receiving the results of scope requests or system permission requests
                             */
                            interface IAuthResultHandler {
                                fun onAuthResult(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    auth: AuthEnum,
                                    result: Boolean
                                )
                            }
                            
                            1. The Host-App implements the IAuthResultHandler interface, receiving the permission request result in the onAuthResult method.

                            Example:

                            class AuthResultHandler : IAuthResultHandler {
                            
                                override fun onAuthResult(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    auth: AuthEnum,
                                    result: Boolean
                                ) {
                                    AlertDialog.Builder(context)
                                        .setTitle("${appInfo.appTitle} Permission Request Result Callback")
                                        .setMessage("Permission: ${auth}, Request Result: $result")
                                        .setPositiveButton("OK") { dialog, which ->
                            
                                        }
                                        .show()
                                }
                            }
                            

                            Parameter Description:

                            Parameter Name Function
                            context Context object
                            appInfo Mini-Program information
                            auth Permission requested this time
                            result Permission request result this time

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as it may lead to null values.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime. Thus, ensure a parameterless constructor is available.
                            • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process. Hence, do not directly access variables from the main process.
                            1. Inject this implementation class during SDK initialization.
                            val config = FinAppConfig.Builder()
                                // Other configurations omitted
                                .setAuthResultHandlerClass(AuthResultHandler::class.java)
                                .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            # 17. IAuthInfoHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game ✅ H5 Application 🚫

                            Starting from version 2.40.3, the Host-App can customize the title and description of the privacy authorization popup.

                            interface IAuthInfoHandler {
                            
                              /**
                               * Get custom title and description for the privacy authorization popup
                               * @param context [Context] instance
                               * @param scope Scope name
                               * @param appInfo Mini-Program information
                               * @param callback Interface callback
                               */ 
                              fun customizeAuthInfo(
                                context: Context,
                                scope: String,
                                appInfo: FinAppInfo,
                                callback: IAuthInfoCallback
                              )
                              
                              /**
                               * When the document link is clicked
                               * @param context [Context] instance
                               * @param appInfo Mini-Program information
                               * @param docName Document name
                               * @param docUrl Document link
                               * @return Whether the click event is handled manually. If the click event is handled manually, return true; the SDK will no longer handle the click event internally. If not, return false, and the SDK will respond with the default logic.
                               */  
                              fun onDocLinkClicked(
                                 context: Context,
                                 appInfo: FinAppInfo,
                                 docName: String?,
                                 docUrl: String?
                              ): Boolean
                            }
                            
                            1. The Host project implements the IAuthInfoHandler interface, customizing it in the customizeAuthInfo method.

                            Example:

                            class AuthInfoHandler : IAuthInfoHandler {
                                override fun customizeAuthInfo(
                                    context: Context,
                                    scope: String,
                                    appInfo: FinAppInfo,
                                    callback: IAuthInfoHandler.IAuthInfoCallback
                                ) {
                                    val authInfo = IAuthInfoHandler.AuthInfo(
                                        "Privacy Authorization Title",
                                        "Privacy Authorization Description"
                                    )
                                    callback.authInfoCallback(authInfo)
                                }
                              
                                override fun onDocLinkClicked(
                                    context: Context,
                                    appInfo: FinAppInfo,
                                    docName: String?,
                                    docUrl: String?
                                ): Boolean {
                                    context.toast("Document ${docName}${docUrl} was clicked")
                                    return true
                                }
                            }
                            

                            Parameter description for the customizeAuthInfo method:

                            Parameter Name Function
                            context Context object
                            scope Mini-Program permission corresponding to this privacy authorization description
                            appInfo Mini-Program information
                            callback Custom privacy authorization description callback

                            Parameter description for the onDocLinkClicked method:

                            Parameter Name Function
                            context Context object
                            appInfo Mini-Program information
                            docName Document name
                            docUrl Document link

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as it may lead to null values.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime. Thus, ensure a parameterless constructor is available.
                            • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process. Hence, do not directly access variables from the main process.
                            1. Inject this implementation class during SDK initialization.
                            val config = FinAppConfig.Builder()
                                // Other configurations omitted
                                .setAuthInfoHandlerClass(AuthInfoHandler::class.java)
                                .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            # 18. IScopeSettingHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            Starting from version 2.40.3, the Host-App can customize the Mini-Program permission settings page.

                            interface IScopeSettingHandler {
                                // Whether to customize the settings page
                                fun customizeSettingPageOnAppletInfo(finApplet: FinApplet): Boolean
                                // Open the settings page
                                fun openCustomizeSettingPage(context: Context, finApplet: FinApplet)
                            }
                            
                            1. The Host project implements the IScopeSettingHandler interface, confirming whether to redirect to a custom page in the customizeSettingPageOnAppletInfo method and performing specific redirection in the openCustomizeSettingPage method.

                            Example:

                            class AuthSettingHandler: IScopeSettingHandler {
                                override fun customizeSettingPageOnAppletInfo(finApplet: FinApplet): Boolean {
                                    return true
                                }
                            
                                override fun openCustomizeSettingPage(context: Context, finApplet: FinApplet) {
                                    val intent = Intent(context, CustomAuthSettingActivity::class.java)
                                    context.startActivity(intent)
                                }
                            }
                            
                            1. Inject this implementation class during SDK initialization.
                            val config = FinAppConfig.Builder()
                                // Other configurations omitted
                                .setScopeSettingHandlerClass(AuthSettingHandler::class.java)
                                .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as it may lead to null values.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime. Thus, ensure a parameterless constructor is available.
                            • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process. Hence, do not directly access variables from the main process.
                            • For custom Activities, add android:multiprocess="true" in the manifest declaration to adapt to the default multi-process mode task stack.
                            • Refer to Custom Mini-Program Permission Settings Page for obtaining the Mini-Program permission list and operating on permissions in the custom page.

                            # 19. ScopeDialogCustomHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game ✅ H5 Application 🚫

                            Starting from version 2.40.11, customization of certain parts of the Scope permission popup is supported.

                            Delegate methods and default implementations are as follows:

                            open class ScopeDialogCustomHandler {
                              
                              /**
                              Whether to insert a custom view into the Scope permission popup. Returning null means no insertion.
                              Custom processing can be done for specific Mini-Programs or specific permissions as needed.
                               */
                              open fun onCustomView(context: Context, finAppInfo: FinAppInfo, scope: AppletScopeBean): View? {
                                return null
                              }
                            
                              /**
                              Whether to hide the built-in permission title and description in the Scope permission popup. Default is false, meaning not hidden.
                               */
                              open fun isHideTitleAndDescription(
                                context: Context,
                                finAppInfo: FinAppInfo,
                                scope: AppletScopeBean
                              ): Boolean {
                                return false
                              }
                            
                              /**
                              Whether to hide the additional options for background location permissions in the Scope permission popup. Default is false, meaning not hidden.
                            
                              For background location permissions, there will be two extra options in the popup compared to other permissions: [While using the Mini-Program] and [While using the Mini-Program and after leaving].
                               */
                              open fun isHideLocationScopeOption(
                                context: Context,
                                finAppInfo: FinAppInfo,
                                scope: AppletScopeBean
                              ): Boolean {
                                return false
                              }
                            
                              /**
                              Whether to hide the built-in [Deny] and [Allow] buttons in the Scope permission popup. Default is false, meaning not hidden.
                              If these two buttons are hidden, make sure to implement corresponding buttons in the custom layout in `onCustomView` and include calls to `deny()` or `allow()`.
                               */
                              open fun isHideButton(
                                context: Context,
                                finAppInfo: FinAppInfo,
                                scope: AppletScopeBean
                              ): Boolean {
                                return false
                              }
                            }
                            
                            1) Inherit the `ScopeDialogCustomHandler` class and override its methods as needed.
                            
                            Example:
                            
                            ```java
                            public class MyScopeUICustom extends ScopeDialogCustomHandler {
                            
                                private View view;
                            
                                @Nullable
                                @Override
                                public View onCustomView(@NonNull Context context,
                                                         @NonNull FinAppInfo finAppInfo,
                                                         @NonNull AppletScopeBean appletScopeBean) {
                                    if (AppletScopeBean.SCOPE_USERINFO.equals(appletScopeBean.getScope())) {
                                        return null;
                                    } else {
                                        view = LayoutInflater.from(context).inflate(R.layout.myview, null);
                                        return view;
                                    }
                                }
                            
                                @Override
                                public boolean isHideTitleAndDescription(@NonNull Context context,
                                                                         @NonNull FinAppInfo finAppInfo,
                                                                         @NonNull AppletScopeBean appletScopeBean) {
                                    return true;
                                }
                            
                                @Override
                                public boolean isHideButton(@NonNull Context context,
                                                            @NonNull FinAppInfo finAppInfo,
                                                            @NonNull AppletScopeBean appletScopeBean) {
                                    return true;
                                }
                            
                                @Override
                                public boolean isHideLocationScopeOption(@NonNull Context context,
                                                                         @NonNull FinAppInfo finAppInfo,
                                                                         @NonNull AppletScopeBean appletScopeBean) {
                                    return true;
                                }
                            }
                            

                            Sample code when setting isHideButton to true:

                            @Nullable
                            @Override
                            public View onCustomView(@NonNull Context context,
                                                     @NonNull FinAppInfo finAppInfo,
                                                     @NonNull AppletScopeBean appletScopeBean) {
                                view = LayoutInflater.from(context).inflate(R.layout.myview, null);
                                Button btnDeny = view.findViewById(R.id.btnDeny);
                                Button btnAllow = view.findViewById(R.id.btnAllow);
                                btnDeny.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        deny();
                                    }
                                });
                                btnAllow.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        allow();
                                    }
                                });
                                return view;
                            }
                            
                            @Override
                            public boolean isHideButton(@NonNull Context context,
                                                        @NonNull FinAppInfo finAppInfo,
                                                        @NonNull AppletScopeBean appletScopeBean) {
                                return true;
                            }
                            

                            For background location permissions, the popup will have two additional options compared to other permissions: ["While Using Mini-Program"] and ["While Using Mini-Program and After Leaving"].

                            If these two options are hidden, it is essential to implement corresponding options in the custom layout within onCustomView, and specify the exact type when calling the allow() method.

                            Sample code when setting isHideLocationScopeOption to true:

                            @Nullable
                            @Override
                            public View onCustomView(@NonNull Context context,
                                                     @NonNull FinAppInfo finAppInfo,
                                                     @NonNull AppletScopeBean appletScopeBean) {
                                view = LayoutInflater.from(context).inflate(R.layout.myview, null);
                                Button btnDeny = view.findViewById(R.id.btnDeny);
                                Button btnAllow = view.findViewById(R.id.btnAllow);
                                CheckBox cbAllowWhenUsing = view.findViewById(R.id.cbAllowWhenUsing);
                                CheckBox cbAllow = view.findViewById(R.id.cbAllow);
                                btnDeny.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        deny();
                                    }
                                });
                                btnAllow.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        if (AppletScopeBean.SCOPE_USER_LOCATION_BACKGROUND.equals(appletScopeBean.getScope())) {
                                            // Special handling for allowing background location permission
                                            if (cbAllowWhenUsing.isChecked()) {
                                                allow(AppletScopeBean.Status.ALLOW_WHEN_USING);
                                            } else {
                                                allow(AppletScopeBean.Status.ALLOW);
                                            }
                                        } else {
                                            // For other permissions, simply call the parameterless method
                                            allow();
                                        }
                            
                                    }
                                });
                                return view;
                            }
                            
                            @Override
                            public boolean isHideLocationScopeOption(@NonNull Context context,
                                                                     @NonNull FinAppInfo finAppInfo,
                                                                     @NonNull AppletScopeBean appletScopeBean) {
                                return true;
                            }
                            
                            1. Inject this implementation class during SDK initialization:
                            val config = FinAppConfig.Builder()
                                // Other configurations omitted
                                .setScopeDialogCustomHandlerClass(MyScopeUICustom::class.java)
                                .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this class. Therefore, avoid storing variable values in this class for use, as it may lead to null values.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime. Ensure that a no-argument constructor is available.

                            # 20. IScopeStatusChangeHandler

                            Supported App Types

                            Mini-Program ✅ Mini-Game ✅ H5 Application 🚫

                            Starting from version 2.41.7, it supports listening to changes in Mini-Program permission settings made by users in the settings page.

                            interface IScopeStatusChangeHandler {
                                fun onScopeStatusChange(
                                    context: Context,
                                    appId: String,
                                    scope: String,
                                    status: AppletScopeBean.Status
                                )
                            }
                            
                            1. The Host-App implements the IScopeStatusChangeHandler interface. Example:
                            class ScopeChangeHandler : IScopeStatusChangeHandler {
                            
                                override fun onScopeStatusChange(
                                    context: Context,
                                    appId: String,
                                    scope: String,
                                    status: AppletScopeBean.Status
                                ) {
                                    Toast.makeText(context, "${appId}, ${scope}: $status", Toast.LENGTH_SHORT).show()
                                }
                            }
                            
                            1. Inject this implementation class during SDK initialization:
                            val config = FinAppConfig.Builder()
                              // Other configurations omitted
                              .setScopeStatusChangeHandler(ScopeChangeHandler::class.java)
                              .build()
                            FinAppClient.init(application, config, finCallback)
                            

                            Note

                            • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this class and may be instantiated multiple times. Therefore, avoid storing variable values in this class for use, as it may lead to null values.
                            • This implementation class will be instantiated via reflection during Mini-Program runtime. Ensure that a no-argument constructor is available.

                            # 21. IFinWatermarkFactory

                            Supported App Types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            The Host-App can implement the IFinWatermarkFactory interface to overlay a custom watermark layer on the Mini-Program interface. Below are the usage instructions.

                            interface IFinWatermarkFactory {
                                
                                /**
                                 * @param context Context object
                                 * @param layoutParams LayoutParams of the View object
                                 * @param finAppInfo Mini-Program information
                                 * @param extra Additional parameters for the watermark, may be null
                                 */
                                fun createWatermarkView(
                                    context: Context,
                                    layoutParams: ViewGroup.LayoutParams,
                                    finAppInfo: FinAppInfo,
                                    extra: JSONObject?
                                ): View
                            }
                            
                            1. Implement the IFinWatermarkFactory interface

                            Code example:

                            class WatermarkViewFactory : IFinWatermarkFactory {
                                
                                /**
                                 * @param context Context object
                                 * @param layoutParams LayoutParams of the View object
                                 * @param finAppInfo Mini-Program information
                                 * @param extra Additional parameters for the watermark, may be null
                                 */
                                override fun createWatermarkView(
                                    context: Context,
                                    layoutParams: ViewGroup.LayoutParams,
                                    finAppInfo: FinAppInfo,
                                    extra: JSONObject?
                                ): View {
                                    // Return your custom View as a watermark overlay on the Mini-Program interface
                                }
                            }
                            
                            1. Set the watermark configuration during initialization
                            ```kotlin
                            val config = FinAppConfig.Builder()
                                // Whether to enable watermark
                                .setEnableWatermark(true)
                                // Implementation class of the IFinWatermarkFactory interface, to be implemented by the Host-App
                                .setWatermarkFactory(WatermarkViewFactory::class.java)
                                // Watermark configuration priority
                                .setWatermarkPriority(FinAppConfigPriority.GLOBAL)
                                // Other configuration items omitted
                                .build()
                            
                            FinAppClient.init(application, config, finCallback)
                            

                            Available priority options:

                            Priority Description
                            FinAppConfigPriority.GLOBAL Default value, global priority, meaning the SDK's global configuration takes precedence.
                            FinAppConfigPriority.SPECIFIED The configuration for the specified AppId takes precedence (see below for details); if not configured, the SDK's global configuration takes precedence.
                            FinAppConfigPriority.APPLET_FILE The Mini-Program's own configuration takes precedence; if the Mini-Program itself is not configured, the specified AppId's configuration takes precedence; if the specified AppId is not configured, the SDK's global configuration takes precedence.

                            # 22. IAppletConfigFactory

                            Supported app types

                            Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                            The host project implements the IAppletConfigFactory interface to make specific configurations for a designated AppId.

                            interface IAppletConfigFactory {
                            
                                fun createAppletConfig(
                                    appId: String,
                                    startParams: FinAppInfo.StartParams?
                                ): FinSpecifiedAppletConfig?
                            }
                            
                            1. Implement the IAppletConfigFactory interface
                              1. Set priority during initialization
                              val appletConfigFactory = MyAppletConfigFactory()
                              val config = FinAppConfig.Builder()
                                  // Screenshot configuration priority at the specified AppId level
                                  .setScreenShotPriority(FinAppConfigPriority.SPECIFIED)
                                  // Watermark configuration priority at the specified AppId level
                                  .setWatermarkPriority(FinAppConfigPriority.SPECIFIED)
                                  // Implementation class of the IAppletConfigFactory interface
                                  .setAppletConfigFactory(appletConfigFactory)
                                  // Other configuration items omitted
                                  .build()
                              

                              # 23. IPrivacyHandler

                              Supported app types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                              Starting from version 2.43.9, custom privacy agreement information is supported.

                              interface IPrivacyHandler {
                              
                                  /**
                                   * Get privacy agreement information
                                   * @param context [Context] instance
                                   * @param appInfo Mini-Program information
                                   * @param callback Callback for obtaining privacy agreement information
                                   */
                                  fun getPrivacyInfo(
                                      context: Context,
                                      appInfo: FinAppInfo,
                                      callback: GetPrivacyInfoCallback
                                  )
                                
                                  /**
                                   * When the document link is clicked
                                   * @param context [Context] instance
                                   * @param appInfo Mini-Program information
                                   * @param docName Document name
                                   * @param docUrl Document link
                                   * @return Whether the click event is handled independently. If the click event is handled independently, return true, and the SDK will no longer handle the click event internally.
                                   * If the click event is not handled independently, return false, and the SDK will respond to the click event according to the default logic.
                                   */
                                  fun onDocLinkClicked(
                                      context: Context,
                                      appInfo: FinAppInfo,
                                      docName: String?,
                                      docUrl: String?
                                  ): Boolean
                              }
                              
                              1. The host project implements the IPrivacyHandler interface and customizes it in the getPrivacyInfo method.

                              Example:

                              class PrivacyHandler : IPrivacyHandler {
                                  override fun getPrivacyInfo(
                                      context: Context,
                                      appInfo: FinAppInfo,
                                      callback: IPrivacyHandler.GetPrivacyInfoCallback
                                  ) {
                                      callback.onSuccess(IPrivacyHandler.PrivacyInfo(
                                          "Privacy Agreement Document Name",
                                          "Privacy Agreement Document Link")
                                      )
                                  }
                                
                                  override fun onDocLinkClicked(
                                      context: Context,
                                      appInfo: FinAppInfo,
                                      docName: String?,
                                      docUrl: String?
                                  ): Boolean {
                                      context.toast("Document ${docName}${docUrl} was clicked")
                                      return true
                                  }
                              }
                              

                              Parameter description for getPrivacyInfo:

                              Parameter Name Function
                              context Context object
                              appInfo Mini-Program related information
                              callback Callback for obtaining privacy agreement information

                              Parameter description for onDocLinkClicked:

                              Parameter Name Function
                              context Context object
                              appInfo Mini-Program related information
                              docName Document name
                              docUrl Document link

                              Note

                              • This implementation class may vary depending on the runtime status of the Mini-Program. Different Mini-Programs may have different instances of this implementation class. Therefore, do not store variable values within this class for use, as this may result in null values.
                              • This implementation class will be instantiated via reflection during the runtime of the Mini-Program. Therefore, ensure that it has a parameterless constructor.
                              • The execution process of this implementation class depends on the Mini-Program process settings. By default, it runs in a child process. Therefore, do not directly access variables in the main process.
                              1. Inject this implementation class during SDK initialization
                              val config = FinAppConfig.Builder()
                                  // Other configurations omitted
                                  .setPrivacyHandlerClass(PrivacyHandler::class.java)
                                  .build()
                              FinAppClient.init(application, config, finCallback)
                              

                              # 24. AppletWebViewLoadHandler

                              Supported app types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                              Starting from version 2.45.11, the Host-App can control whether WebView can load H5 links.

                                  interface UrlCanLoadCallback {
                                      /**
                                       * Callback to determine whether the URL can be loaded.
                                       */
                                      fun onResult(canLoad: Boolean)
                                  }
                              
                                  open fun webviewCanLoadUrl(context: Context, appInfo: FinAppInfo, url: String, callback: UrlCanLoadCallback) {
                                      callback.onResult(true)
                                  }
                              
                              

                              Example Code

                              1. The Host-App extends AppletWebViewLoadHandler and overrides webviewCanLoadUrl(context: Context, appInfo: FinAppInfo, url: String, callback: UrlCanLoadCallback).

                              Translated content:

                              class MyAppletWebViewLoadHander: AppletWebViewLoadHandler() {
                              
                                  override fun webviewCanLoadUrl(
                                      context: Context,
                                      appInfo: FinAppInfo,
                                      url: String,
                                      callback: UrlCanLoadCallback
                                  ) {
                                      Log.d("Test-webviewCanLoadUrl", url)
                                      AlertDialog.Builder(context)
                                          .setTitle("URL Loading Confirmation")
                                          .setMessage("Allow loading $url ?")
                                          .setPositiveButton("Allow") { _, _ -> callback.onResult(true) }
                                          .setNegativeButton("Reject") { _, _ -> callback.onResult(false) }
                                          .show()
                                  }
                              }
                              
                              
                              1. When initializing the SDK, set the class that implements the delegate
                              val config = FinAppConfig.Builder()
                                  // Other configurations omitted
                                  .setAppletWebViewLoadHandlerClass(MyAppletWebViewLoadHander::class.java)
                                  .build()
                              FinAppClient.init(application, config, finCallback)
                              

                              # 25. AppletConfigHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                              Supported starting from version 2.46.13 (split from IAppletHandler). When using multiple processes for Mini-Programs, it needs to be set in the Mini-Program process; when using a single process, it needs to be set in the main process.

                              open class AppletConfigHandler {
                              
                                  open fun getJSSDKConfig(json: JSONObject, callback: IAppletHandler.IAppletCallback) {
                              
                                  }
                              
                                  /**
                                   * Get custom cookies used for loading Mini-Program web-view components
                                   */
                                  open fun getWebViewCookie(appId: String): Map<String, String>? {
                                      return null
                                  }
                              }
                              
                              

                              Example code:

                              FinAppProcessClient.appletConfigHandler = object : AppletConfigHandler() {
                                  override fun getJSSDKConfig(json: JSONObject, callback: IAppletHandler.IAppletCallback) {
                              
                                  }
                              
                                  override fun getWebViewCookie(appId: String): Map<String, String>? {
                                      val cookie = HashMap<String, String>()
                                      cookie["a"] = "a\n"
                                      cookie["b"] = "b\r"
                                      cookie["c"] = "c\u0000"
                                      return cookie
                                  }
                              }
                              

                              # 26. AppletGrayVersionHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game ✅ H5 Application ✅

                              Supported starting from version 2.46.13 (split from IAppletHandler), set in the main process.

                              open class AppletGrayVersionHandler {
                              
                                  /**
                                   * Get gray release configuration parameters
                                   *
                                   * @param appId Mini-Program ID
                                   * @return Gray release configuration parameters
                                   */
                                  open fun getGrayAppletVersionConfigs(appId: String): List<GrayAppletVersionConfig>? {
                                      return null
                                  }
                              
                              }
                              

                              Example code:

                              FinAppClient.grayVersionHandler = object : AppletGrayVersionHandler() {
                                  override fun getGrayAppletVersionConfigs(appId: String): List<GrayAppletVersionConfig>? {
                                      return null
                                  }
                              }
                              

                              # 27. AppletInteractionHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game ✅ H5 Application 🚫

                              Supported starting from version 2.47.7.

                              open class AppletInteractionHandler {
                              		/**
                              		image component, previewImage, previewMedia long press delegate
                              		**/
                                  open fun mediaLongPressed(context:Context, appId: String, mediaInfo: FinMediaInfo) : Boolean {
                                      return false
                                  }
                              
                              }
                              

                              Example code:

                              FinAppProcessClient.appletInteractionHandler = object : AppletInteractionHandler() {
                                  override fun mediaLongPressed(
                                      context: Context,
                                      appId: String,
                                      mediaInfo: FinMediaInfo
                                  ): Boolean {
                                      Log.e("mediaLongPressed", "appId:$appId, mediaInfo:$mediaInfo")
                                      // Create an AlertDialog with multiple options
                                      val items = arrayOf("Scan QR Code", "Save", "Copy", "Share")
                                      val message = "type:${mediaInfo.mediaType},mediaUrl:${mediaInfo.mediaUrl}"
                                      AlertDialog.Builder(context)
                                          .setTitle("Custom Media Long Press Delegate Dialog")
                                          .setItems(items) { dialog, which ->
                                              val text = items[which]
                                              Toast.makeText(context, "$text menu clicked, $message", Toast.LENGTH_LONG).show()
                                          }
                                          .setNegativeButton("Cancel") { dialog, _ ->
                                              dialog.dismiss()
                                          }
                                          .show()
                                      return true
                                  }
                              
                              }
                              

                              # 28. AppletHomeBackPressedHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                              Supported starting from version 2.47.9.

                              open class AppletHomeBackPressedHandler {
                              
                                  /**
                                   * Mini-Program home page, swipe back and virtual back button delegate event
                                   * @param appId Mini-Program ID
                                   * @return Whether to override the default logic. true: Handle onBackPressed on the Mini-Program home page yourself; false: Use the default logic in the SDK (i.e., close the Mini-Program)
                                   */
                                  open fun onAppletHomeBackPressed(context: Context, appId: String): Boolean {
                                      return false
                                  }
                              }
                              

                              Example code:

                              FinAppProcessClient.appletHomeBackPressedHandler = object : AppletHomeBackPressedHandler() {
                                  override fun onAppletHomeBackPressed(context: Context, appId: String): Boolean {
                                      AlertDialog.Builder(context)
                                          .setTitle("Override Swipe Back Functionality")
                                          .setMessage("Confirm exit application?")
                                          .setNegativeButton("Cancel") { dialog, _ ->
                                              dialog.dismiss()
                                          }
                                          .setNeutralButton("Force Exit") { dialog, which ->
                                              FinAppClient.appletApiManager.closeApplet(appId)
                                          }
                                          .show()
                                      return true
                                  }
                              }
                              

                              # 29. AppletTraceHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                              Note

                              • The FinAppProcessClient class needs to be used in the Mini-Program process. Please use the FinAppClient.INSTANCE.isFinAppProcess() method to determine if it is in the Mini-Program process.

                              • The delegate methods in AppletTraceHandler will execute in the Mini-Program process.

                              open class AppletTraceHandler {
                              
                                interface Callback {
                                  /**
                                   * Whether to agree to authorization
                                   *
                                   * @param allow true Agree, false Reject
                                   */
                                  fun allowAuthorization(allow: Boolean)
                                }
                              
                                /**
                                 * Request user authorization
                                 */
                                open fun requestUserAuthorization(context: Context, appId: String, callback: Callback) {
                                  callback.allowAuthorization(false)
                                }
                              }
                              

                              Example code:

                              FinAppProcessClient.appletTraceHandler = object : AppletTraceHandler() {
                                override fun requestUserAuthorization(
                                  context: Context,
                                  appId: String,
                                  callback: Callback
                                ) {
                                  AlertDialog.Builder(context).apply {
                                    setTitle("Authorization Reminder")
                                    setMessage("Do you agree to authorize enabling trace-back functionality?")
                                    setPositiveButton("Agree") { dialog, _ ->
                                      callback.allowAuthorization(true)
                                      dialog.dismiss()
                                    }
                                    setNegativeButton("Disagree") { dialog, _ ->
                                      callback.allowAuthorization(false)
                                      dialog.dismiss()
                                    }
                                    create().show()
                                  }
                                }
                              }
                              

                              # 30. AppletXComponentHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application 🚫

                              Starting from version 2.48.7, custom native Views support same-layer rendering. Notes:

                              1. X5 must be used to enable this feature;
                              2. Currently, only relatively common Views are supported; complex View components may encounter issues, and specific cases can be tested independently (e.g., complex components like Video, EditText, Camera, etc., have corresponding same-layer components, but custom same-layer components cannot render internally).
                              3. Supported View component types include: ImageView, TextView, Button, LinearLayout (other common ViewGroup), etc.

                              The proxy methods and their default implementations are as follows:

                                 abstract class AppletXComponentHandler {
                                     
                                lateinit var xParams: XComponentParams  // Read-only, not writable
                                  internal set
                              
                                lateinit var xComponentView: View  // Read-only, not writable
                                  internal set
                                
                                /**
                                 * Create the XComponent component
                                 *
                                 * @param xParams XComponent parameters
                                 * @param activity Current Activity
                                 * @return Returns the created View component (native View for same-layer rendering)
                                 *
                                 */
                                abstract fun createXComponent(xParams: XComponentParams, activity: Activity): View
                              
                                /**
                                 * Update the XComponent component
                                 *
                                 * @param xParams XComponent parameters
                                 * @param activity Current Activity
                                 * @param xComponent The already created same-layer rendered View component
                                 */
                                open fun updateXComponent(xParams: XComponentParams, activity: Activity, xComponent: View) {
                                  FLog.d(TAG, "updateXComponent: xParams = $xParams")
                                }
                              
                                /**
                                 * Destroy the XComponent component
                                 * @param xParams XComponent parameters
                                 * @param activity Current Activity
                                 * @param xComponent The already created same-layer rendered View component
                                 */
                                open fun destroyXComponent(xParams: XComponentParams, activity: Activity, xComponent: View) {
                                  (xComponent.parent as? ViewGroup)?.removeView(xComponent)
                                }
                              
                                /**
                                 * Send an event to the Mini-Program's XComponent component
                                 * @param eventName Event name
                                 * @param params Event parameters
                                 * @param id Component ID, taken from the id field of XComponentParams
                                 */
                                fun sendEventToXComponent(eventName: String, params: JSONObject, id: String) {
                                    // This method cannot be overridden; internal implementation omitted
                                }
                              
                                /**
                                 * Receive events sent from the Mini-Program's XComponent component
                                 * @param eventName Event name
                                 * @param data Event data
                                 * @param id Component ID, taken from the id field of XComponentParams
                                 * @param callback Return data to the Mini-Program (if no data needs to be returned, pass null as the callback parameter, but it must be called)
                                 */
                                open fun receiveXComponentEvent(
                                  eventName: String,
                                  data: JSONObject,
                                  id: String,
                                  callback: (params: JSONObject?) -> Unit
                                ) {
                                }
                                
                              } 
                              
                              

                              Partial parameter description:

                              
                              /**
                               * XComponentParams is used to describe the parameters of the XComponent component
                               * - style: Style information of the component (only includes width and height)
                               * - xComponentId: Unique identifier of the component
                               * - tag: Tag name of the component (defined in the Mini-Program)
                               * - id: The ID defined for the component in the Mini-Program (must not be duplicated across components)
                               * - data: Data of the component
                               * - appInfo: Mini-Program information (read-only, cannot be modified)
                               * - pagePath: Path of the current page where the component resides
                               */
                              data class XComponentParams(
                                  val style: XStyle,
                                  val xComponentId: String,
                                  val tag: String,
                                  val id: String,
                                  val data: JSONObject,
                                  val appInfo: FinAppInfo,
                                  val pagePath: String
                              )
                              
                              /**
                               * XStyle is used to describe the style information of the XComponent component
                               * - width: Width of the component
                               * - height: Height of the component
                               */
                              data class XStyle(val width: Float, val height: Float)
                              
                              
                              1. Inherit the AppletXComponentHandler class and override its methods as needed.

                              Example:

                              public class AppletXComponentHandlerImpl extends AppletXComponentHandler {
                              
                                public static final String BUTTON_TAG = "button";
                              
                                @NotNull
                                @Override
                                public View createXComponent(@NotNull XComponentParams xParams, @NotNull Activity activity) {
                                  // The tag comes from the tag attribute value of the x-component tag on the Mini-Program side
                                  // Note: The returned View must not be null
                                  switch (xParams.getTag()) {
                                    case BUTTON_TAG:
                                      // Create a native View
                                      View view = View.inflate(activity, R.layout.fin_applet_xcomponet, null);
                                      TextView tvXComponent = view.findViewById(R.id.tvXComponent); // If this View is needed elsewhere, you can save a reference here as a global variable
                                      // Get the data passed from the Mini-Program and set it on the native View
                                      // Data reception should be agreed upon between the Mini-Program side and the native side
                                      JSONObject data = xParams.getData();
                                      tvXComponent.setText(data.optString("text"));
                              
                                      tvXComponent.setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                          try {
                                            // Send data to the Mini-Program's component under certain conditions
                                            // Define the event name and data format
                                            String eventName = "AppClickEvent";
                                            JSONObject data = new JSONObject();
                                            data.put("message", "Hello from app!");
                                            String id = xParams.getId(); // Fixed usage
                                            sendEventToXComponent(eventName, data, id);
                                          } catch (Exception e) {
                                            e.printStackTrace();
                                          }
                                        }
                                      });
                              
                                      return view;
                              
                                    case "xxxx":
                                      // Other types of native Views can be created here
                                      // Code omitted
                                      return new TextView(activity);
                                  }
                                  TextView defaultTextView = new TextView(activity);
                                  defaultTextView.setText("Unimplemented tag, displaying default text");
                                  return defaultTextView;
                                }
                              
                                @Override
                                public void updateXComponent(@NotNull XComponentParams xParams, @NotNull Activity activity, @NotNull View xComponent) {
                                  // Logic to update the native View
                                  // Note: This method will be called whenever there are changes in the Mini-Program's data (UI width/height), synchronizing the data here
                                  switch (xParams.getTag()) {
                                    case BUTTON_TAG:
                                      // The xComponent here is the View returned by createXComponent
                                      // If you don't want to call findViewById again, you can save a reference to the TextView in createXComponent
                                      TextView tvXComponent = xComponent.findViewById(R.id.tvXComponent);
                                      // Update the TextView's text
                                      tvXComponent.setText(xParams.getData().optString("text"));
                                      break;
                                    case "xxxx":
                                      // Update other types of native Views
                                      // Code omitted
                                      break;
                                  }
                                }
                              
                                @Override
                                public void destroyXComponent(@NotNull XComponentParams xParams, @NotNull Activity activity, @NotNull View xComponent) {
                                  super.destroyXComponent(xParams, activity, xComponent);
                                  // This method is called when the Mini-Program's page is destroyed; resources can be released or cleanup performed here
                                  // Note: super.destroyXComponent(xParams, activity, xComponent); must be called, as it releases related Views internally
                                }
                              
                                @Override
                                public void receiveXComponentEvent(@NonNull String eventName, @NonNull JSONObject data, @NonNull String id, @NonNull Function1<? super JSONObject, Unit> callback) {
                                  // Receive events sent from the Mini-Program side here
                                  // Note: eventName is the event name defined on the Mini-Program side, and data is the data passed from the Mini-Program side
                                  switch (eventName) {
                                    case "miniProgramEvent":
                                      // Handle events sent from the Mini-Program side
                                      String message = data.optString("message");
                                      // Data can be processed here
                                      // For UI updates, it's better to use the above method [updateXComponent]
                                      // If you must handle UI here, you can access the View and other xParams data, though it's not recommended
                                      // this.xComponentView
                                      // this.xParams
                                      TextView tvXComponent = this.xComponentView.findViewById(R.id.tvXComponent);
                                      tvXComponent.setText(message);
                              
                                      break;
                              
                                    // Other event handling logic can be added here
                                    case "xxxxx":
                                      // Handle other events
                                      // Code omitted
                                      break;
                                  }
                              
                                  try {
                                    // Finally: Some data can be passed back to the Mini-Program side here (if not called, the Mini-Program won't receive a callback indicating whether the data was sent successfully)
                                    // If no data is being transmitted, pass null
                                    JSONObject dataBack = new JSONObject();
                                    dataBack.put("text", "xxxx");
                                    callback.invoke(dataBack);
                                  } catch (Exception e) {
                                    e.printStackTrace();
                                  }
                                  
                                }
                              }
                              
                              
                              1. When initializing the SDK, set the class implementing the proxy:
                              val config = FinAppConfig.Builder()
                                  // Other configurations omitted
                                .setAppletXComponentHandlerClass(AppletXComponentHandlerImpl::class.java)
                                .build()
                              FinAppClient.init(application, config, finCallback)
                              
                              1. Simple Mini-Program example snippet:
                                
                                  <x-component id='XComponent' tag='button'  bindtap="bindViewTap" data="{{componentData}}" style="width:300px;height:300px;" />
                                  <!-- id corresponds to xParams.getId() in the native code -->
                                  <!-- tag corresponds to xParams.getTag() in the native code -->
                                  <!-- data corresponds to xParams.getData() in the native code -->   
                              
                              // Mini-Program JS code on the Mini-Program side
                              Page({
                                  data: {
                                      componentData: {
                                          text: "Mini-Program side data XXXX"
                                      }
                                  },
                                  bindViewTap: function (e) {
                                      this.xContext = wx.createXComponentContext('XComponent')
                                      
                                      // Accept events sent from the native side to the Mini-Program side
                                      // Multiple listeners can be set, one per execution, with corresponding off methods to cancel listening;
                                      // Generally, it is not recommended to set up listeners within click events; this is merely an example of API usage.
                                      this.xContext.on('AppClickEvent', res => {
                                      console.log('AppClickEvent', res)
                                  })
                                      // Send events to the native side
                                      this.xContext.publish('miniProgramEvent', {
                                          message: "hello from applet",
                                          success(res) {
                                              console.log('miniProgramEvent complete', res)
                                          }
                                      })
                                  }
                              });
                              

                              # 31. ICustomScopeRequestHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game ✅ H5 Application ✅

                              Note

                              • Starting from version 2.49.3: Custom permission request dialog interface proxy;
                              open class ICustomScopeRequestHandler {
                              
                                /**
                                 * Permission request handling
                                 * Note: The final permission processing result must call scopeResult; otherwise, the permission request process cannot proceed.
                                 * @param context
                                 * @param appInfo Mini-Program information
                                 * @param scopeInfo Permission information
                                 * @param scopeResult Permission request result callback
                                 * @return true - indicates handling the permission request independently, false - indicates not handling and delegating to the default permission request handling process
                                 */
                                open fun onScopeRequest(
                                  context: Context,
                                  appInfo: FinAppInfo,
                                  scopeInfo: ScopeInfo,
                                  scopeResult: (status: AppletScopeBean.Status) -> Unit
                                ): Boolean {
                                  return false
                                }
                              
                                /**
                                 * Whether to automatically write permissions to local storage;
                                 * true - write
                                 * false - do not write (this means authorization is successful, but the Mini-Program does not record the authorization result internally, prompting for authorization every time)
                                 */
                                open fun autoWriteScopeAfterRequest(
                                  context: Context,
                                  appInfo: FinAppInfo,
                                  scopeInfo: ScopeInfo
                                ): Boolean {
                                  return true
                                }
                              }
                              

                              Partial parameter description:

                              
                              data class ScopeInfo(
                                  /**
                                   * Permission name constant
                                   */
                                  val scopeName: String,
                                  /**
                                   * Permission description
                                   */
                                  val scopeDesc: String?,
                                  /**
                                   * Detailed permission description
                                   */
                                  val scopeDetailDesc: String?,
                                  /**
                                   * Custom privacy policy document name
                                   */
                                  val customPrivacyDocName: String?,
                                  /**
                                   * Custom privacy policy URL address
                                   */
                                  val customPrivacyDocUrl: String?
                              )
                              
                              

                              Example code:

                              1. Inherit the ICustomScopeRequestHandler class and override its methods as needed;
                              class CustomScopeRequestHandlerImpl : ICustomScopeRequestHandler() {
                                override fun onScopeRequest(
                                  context: Context,
                                  appInfo: FinAppInfo,
                                  scopeInfo: ScopeInfo,
                                  scopeResult: (status: AppletScopeBean.Status) -> Unit
                                ): Boolean {
                                  AlertDialog.Builder(context)
                                    .setTitle("${scopeInfo.scopeDesc}")
                                    .setMessage(
                                      "Detailed permission description ${scopeInfo.scopeDetailDesc}\n\n" +
                                              "Custom privacy policy document name: ${scopeInfo.customPrivacyDocName}\n\n" +
                                              "Custom privacy policy URL: ${scopeInfo.customPrivacyDocUrl}"
                                    ).apply {
                                      if (scopeInfo.scopeName == AppletScopeBean.SCOPE_USER_LOCATION_BACKGROUND) {
                                        setNeutralButton("Allow while in use") { _, _ ->
                                          scopeResult(AppletScopeBean.Status.ALLOW_WHEN_USING)
                                        }
                                      }
                                    }
                                    .setPositiveButton("Allow") { _, _ -> scopeResult(AppletScopeBean.Status.ALLOW) }
                                    .setNegativeButton("Deny") { _, _ -> scopeResult(AppletScopeBean.Status.DISALLOW) }
                                    .create().show()
                                  
                                  
                                  return true // Note that returning true indicates handling the permission request independently
                                }
                              
                                // This method can be left unoverridden, defaulting to returning true
                                // Indicates that after a successful permission request, the permission will be automatically written to local storage
                                // If you do not want to write to local storage and prefer to manage the local state of permissions yourself, return false
                                override fun autoWriteScopeAfterRequest(
                                  context: Context,
                                  appInfo: FinAppInfo,
                                  scopeInfo: ScopeInfo
                                ): Boolean {
                                  return true
                                }
                              
                              }
                              
                              1. When initializing the SDK, set the class implementing the proxy
                              val config = FinAppConfig.Builder()
                                  // Other configurations omitted
                                  .setCustomScopeRequestHandlerClass(CustomScopeRequestHandlerImpl::class.java)
                                  .build()  
                              FinAppClient.init(application, config, finCallback)
                              

                              # 32. AppletWebViewURLRouterHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game 🚫 H5 Application ✅

                              Note

                              • Starting from version 2.49.7: Custom permission request dialog interface proxy;
                              /**
                               *
                               * WebView tag in Mini-Programs and H5 application page URL routing notification proxy
                               */
                              open class AppletWebViewURLRouterHandler {
                              
                                /**
                                 * Handle WebView URL routing change events
                                 * @param activity Current Activity
                                 * @param appInfo Mini-Program information
                                 * @param url Current URL
                                 * @param isBlocked Whether blocked
                                 * @param pagePath Current page path
                                 * @return Return true to indicate enabling this proxy, just a marker
                                 */
                                open fun onWebViewURLRouterChangeEvent(
                                  activity: Activity,
                                  appInfo: FinAppInfo,
                                  url: String,
                                  isBlocked: Boolean,
                                  pagePath: String
                                ): Boolean {
                                  return false
                                }
                              }
                              

                              Example code:

                              1. Inherit the AppletWebViewURLRouterHandler class and override its methods as needed;
                              class MyAppletWebViewURLRouterHandler : AppletWebViewURLRouterHandler() {
                              
                                override fun onWebViewURLRouterChangeEvent(
                                  activity: Activity,
                                  appInfo: FinAppInfo,
                                  url: String,
                                  isBlocked: Boolean,
                                  pagePath: String
                                ): Boolean {
                                  FLog.d(
                                    "RouterHandler",
                                    "onWebViewURLRouterChangeEvent: url=$url, isBlocked=$isBlocked, pagePath=$pagePath , appId=${appInfo.appId}"
                                  )
                                  return true
                                }
                              }
                              
                              1. When initializing the SDK, set the class implementing the proxy
                              val config = FinAppConfig.Builder()
                                  // Other configurations omitted
                                  .setAppletWebViewURLRouterHandlerClass(MyAppletWebViewURLRouterHandler::class.java)
                                  .build()  
                              FinAppClient.init(application, config, finCallback)
                              

                              # 33. AppletBackPressedHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game ✅ H5 Application ✅

                              Note

                              • Starting from version 2.50.7: Custom permission request dialog interface proxy;
                              
                              open class AppletBackPressedHandler {
                              
                                  /**
                                   * Mini-Program page, swipe and virtual back button proxy event
                                   *
                                   * @param context Context
                                   * @param appId Mini-Program ID
                                   * @param info Mini-Program page information
                                   * @return Whether to override the default logic. true: Indicates handling onBackPressed for Mini-Program pages independently; false: Use the default logic in the SDK
                                   */
                                  open fun onAppletBackPressed(
                                      context: Context,
                                      appId: String,
                                      info: AppletBackPressedInfo
                                  ): Boolean {
                                      return false
                                  }
                              }
                              
                              /**
                               * Mini-Program page information
                               * @param isHomePage Whether it is the home page
                               * @param pagePath Page path
                               */
                              data class AppletBackPressedInfo(val isHomePage: Boolean, val pagePath: String)
                              
                              
                              

                              Example code:

                                 // Configure within the Mini-Program process
                                 FinAppProcessClient.appletBackPressedHandler = object : AppletBackPressedHandler() {
                                  override fun onAppletBackPressed(
                                      context: Context,
                                      appId: String,
                                      info: AppletBackPressedInfo
                                  ): Boolean {
                                      Log.d(
                                          TAG,
                                          "onAppletBackPressed: $appId, ${info.isHomePage}, ${info.pagePath}"
                                      )
                                      // Note that this needs to be overridden, otherwise interception won't occur
                                      return true
                                  }
                                }
                              

                              # 34. IEventReportHandler

                              Supported App Types

                              Mini-Program ✅ Mini-Game ✅ H5 Application ✅

                              Note

                              • Starting from version 2.51.3: Host-App takes over SDK data reporting events;
                              interface IEventReportHandler {
                              
                                  /**
                                   * Receive reportEvent data
                                   * @param reportEvent Passed reportEvent object
                                   */
                                  fun onReportEventReceived(reportEvent: ReportEvent)
                              
                              }
                              

                              Example code:

                              1. Implement the IEventReportHandler proxy
                              class MyReportHandler : IEventReportHandler {
                              
                                  override fun onReportEventReceived(reportEvent: ReportEvent) {
                                      Log.d("MyReportHandler", "onReportEventReceived: $reportEvent")
                                  }
                              }
                              
                              1. When initializing the SDK, set the class implementing the proxy
                              val config = FinAppConfig.Builder()
                                  // Other configurations omitted
                                .setEventReportHandler(MyReportHandler())
                                .build()
                              FinAppClient.init(application, config, finCallback)
                              
                              © FinClip with ❤ , Since 2017