Mini Program Weixin DevTools provide a simulation of the Weixin app. Limited by the differences between desktops and mobile devices and some unique Weixin data. To make development more convenient, some APIs are different in the DevTools than in Weixin.
API for QR Code Scanning
Unlike scanning a QR code with a mobile camera, it is inefficient to call the camera on a PC or Mac to scan a QR code. As a result, after calling the scanning API for the first time, developers can select a local image for subsequent logical debugging instead of actually calling the camera. Despite the procedural difference, the input and output of the API are the same.
The latest version of Weixin DevTools supports WeChat Pay debugging, but the operation differs from calling WeChat Pay on a mobile device due to security concerns:
- Newly registered developers have to wait 24 hours before acquiring the permission to debug WeChat Pay.
- Weixin DevTools will display a QR code after the developer calls the WeChat Pay API. The developer has to scan the QR code on a mobile device using the development Weixin ID to complete the mobile payment.
- The DevTools will synchronize the response package of the mobile payment to allow the developer to carry out subsequent operations.
The interactions are different, but the API input and output of the DevTools are consistent with the app.
Enable Custom Parameters
For routine use, you can open a Mini Program via QR code or sharing. Then, you will be redirected to the corresponding Mini Program page (does not have to be the homepage) based on the set startup page:
path that can include the parameter:
query. In Weixin DevTools, developers can also debug different startup pages and parameters through custom compilation conditions.
For example, the figure below uses the startup page
page/API/index and parameter
Entry Scene Values
In the Weixin app, users can open a Mini Program in various scenarios Details. However, Weixin DevTools lacks the environment to simulate these scenarios. Developers can debug various scenarios through compilation conditions.
Calling forward is a simulated behavior in Weixin DevTools and will not actually forward to other users. This simulation allows developers to check that the forward API is called directly.
Forward with shareTicket
A forward with
shareTicket can provide more forward information, such as the name of the group chat and the group tags
openGId. In Mini Program Weixin DevTools, developers can debug a forward with
shareTicket using the following method.
When the parameter
withShareTicket for the call to wx.showShareMenu is
true, click the forward button in the upper-right menu of the simulator to display a list of test groups, as shown in the following figure:
You can click any group to obtain
shareTicket from the API response package and get the related forward information by calling wx.getShareInfo.
When you need to debug a scene with
shareTicket opened from a group, you can use the
Mini Program message card from 1044:group chat (with shareTicket) and select any simulated test group, as shown in the following figure:
Preview with Custom Compilation Conditions
As with Enable Custom Parameters, when submitting a preview, developers can debug different startup pages and parameters on mobile devices through the custom preview function. We can select the already created custom compilation conditions to preview.
Debugging Support for Mini Program Redirection
The development and debugging of Mini Program redirection include two parts.
Debug Mini Program for Correct Redirection
To ensure the security of the Mini Program code, calling wx.navigateToMiniProgram will not actually open and redirect to another Mini Program in Weixin DevTools, but Weixin DevTools will check the link connection between the current Mini Program and the Mini Program redirected to and output the related information to developers. This lets developers determine whether the call is successful based on the callback function.
Debug Opened Mini Program for Correct Parameter Receipt
Select Custom Compilation to enter the scene, select 1037 Enter From Mini Program to check whether the opened Mini Program has received the parameters and processed them correctly.
Select Custom Compilation to enter the scene, select 1038 Return From Mini Program to check whether the parameters are received and processed correctly when returning from a Mini Program.