# Custom Sharing FAQ

To meet the sharing scenario requirements of different Apps, the FinClip Mini-Program SDK supports developers configuring a shareSDK URL on the client side and directing it to a landing page to complete the sharing operation.

# 1. Implementing the Landing Page

After configuring the landing page address in the client App, when a customer clicks to open the landing page, they will access a URL formatted as ${url}?params=xxxxx. During this process, the H5 page can read the param parameter, perform Base64 decoding, and obtain the sharing parameters.

Sample code is as follows:

const { params } = query;
const {
   screenshotUrl,  // Screenshot URL of the shared page
   miniAppName, // Mini-Program name
   miniAppDesc, // Mini-Program description
   miniAppLogo, // Mini-Program logo
   miniAppId, // Mini-Program appId
   miniAppLink, // App wake-up scheme
   wechatAppId, // WeChat Mini-Program ID
   miniAppPath, // Mini-Program page path
   miniAppQuery, // Mini-Program page parameters
 } = Object.fromEntries(new URLSearchParams(window.atob(decodeURIComponent(params))));

# 2. Opening the Mini-Program via Scheme Redirect in the App

The client App can also directly access Mini-Program content using the scheme window.location.href = miniAppLink. During this process, the App must configure the scheme redirect according to the documentation below, and the scheme configured in iOS and Android operating systems must be consistent.

Reference links are as follows:

# 3. Methods for Opening External Mini-Programs in WeChat

There are two main solutions for opening a Mini-Program within WeChat and implementing custom sharing functionality: one involves detecting the WeChat browser User Agent (UA), and the other uses the WeChat JS-SDK for guidance.

# Solution 1: Detect WeChat UA and Add a Floating Window Prompting to Open in Browser

This method is relatively straightforward. It identifies the browser by the UA string returned in the frontend page. When the UA header includes MicroMessenger, a prompt is added to the page guiding the user to open the current page in the "system default browser," which then redirects to the proprietary App.

# Solution 2: Using the WeChat JS-SDK

  1. First, navigate to "Function Settings" under "Official Account Settings" in the WeChat Official Account Platform and configure the "JS Interface Security Domain."

  2. Then, initialize the WeChat JS-SDK, which mainly includes the following: A. Declaration of relevant fields

    appId: '', // Required, the unique identifier of the official account
    timestamp: , // Required, the timestamp for generating the signature
    nonceStr: '', // Required, the random string for generating the signature
    signature: '',// Required, the signature
    

    B. Inject permission verification configuration via the config interface. For details, refer to here (opens new window) C. For the AppID, fill in the AppID of a verified Mini-Program under a non-individual entity D. Generate the signature using the permission signature algorithm. For details, see here (opens new window)

  3. The WeChat Open Platform SDK needs to be introduced in the App. Refer to here (opens new window) for related configuration, then obtain the AppID of the mobile application in the Open Platform;

  4. Use the development tag to open the link in the App. For the operation method, see here (opens new window)

© FinClip with ❤ , Since 2017