Table of Contents

Run the WeChat Mini Program Mega plugin sample project quickly

This article will introduce how to quickly run the sample project for the WeChat Mini Program Mega plugin. You will learn how to:

  • Set up and configure the development environment for the sample project.
  • Run part of the sample functionality: using Mega cloud-based localization.

Before you begin

Confirm the mini program entity is an enterprise entity

Important

The Mega Mini Program plugin only supports enterprise entities. Mini programs with personal entity types cannot use the Mega Mini Program plugin.

Confirm that in the Mini Program backend, Settings > Basic Information > Entity Information displays Enterprise Legal Person or Individual Business.

Since Mega functionality is provided as a mini program plugin, you must have a WeChat Mini Program with an enterprise entity as the host environment.

Even if you only want to run our sample project, you need to configure your own WeChat Mini Program AppID to debug and preview in the developer tools.

Download the sample project

  1. Go to the Development Tools Download Page.

  2. Confirm the EasyAR Privacy Policy and click Download.

    Download Sample

  3. After downloading, unzip the .zip package locally.

Configure the sample project

  1. Log in to the WeChat Mini Program Developer Tools.

  2. Import the sample project using the WeChat Mini Program Developer Tools.

    • After opening the developer tools, click the import button and select the locally extracted directory.

    Import developer tools

    Select local directory

    • Ensure the AppID matches the AppID filled in when applying for the Mega license, and the development mode is Mini Program. Click create.
    Note

    Inconsistent AppID will cause license verification failure.

    Import developer tools options

  3. Configure mega license and cloud services

    Open the file miniprogram/components/sample-data/easyar-settings.ts and fill in the corresponding fields with the license and service information from the preparation work:

    • Mega License
    /** Your mini program's mega license */
    export const EasyARLicenseKey: string = "";
    
    How to obtain a mega WeChat mini program license

    Select Mega WeChat Mini Program in the EasyAR Development Center.

    License list

    The list should contain the Mega WeChat Mini Program License you want to use. (If no available license exists, verify if your account is the same as the one used to create the Mega positioning library).

    Click the mini program name to obtain its Mega license (click the copy button on the right, then paste it into the easyar-settings.ts file as the value of EasyARLicenseKey). Confirm that the associated AppID exactly matches your WeChat mini program AppID.

    License details


    • Cloud service API key and secret
    /** Your cloud service API key and secret */
    export const EasyARAPIKey: string = "";
    export const EasyARAPISecret: string = "";
    
    How to obtain cloud service API key and secret

    Select Cloud Service API Key in the EasyAR Development Center.

    If you have previously created cloud service API key and secret, copy them from the right side here and paste them into the easyar-settings.ts file as values for EasyARAPIKey and EasyARAPISecret.

    Cloud service API key

    If you haven't created them before, create them as follows:

    In the EasyAR Development Center, select Cloud Service API Key > Create API key.

    Create API key

    Create API key details

    Enter the application name, select the cloud services to use: Mega Block and/or Mega Landmark, then click OK.


    • Cloud service server address and AppID:
    /** Your mega cloud positioning library's server address and AppID */
    export const MegaTrackerServerAddress: string = "";
    export const MegaTrackerAppID: string = "";
    
    How to obtain the mega cloud positioning library's server address and AppID

    Select Block Cloud Positioning in the EasyAR Development Center, then choose your Mega Cloud Positioning Service Group.

    Select cloud positioning service group

    Select your mega cloud positioning library:

    Select cloud positioning library

    Obtain cloud positioning information

    Click Key, then obtain the positioning library's AppID and Server Address below (click the copy button on the right, then paste them into the easyar-settings.ts file as values for MegaTrackerAppID and MegaTrackerServerAddress).

Run the sample on a physical device

  1. Click the real-device preview button on the top bar of the Mini Program development tool, and load it onto your development phone by scanning the QR code.

    Caution

    You cannot directly simulate and run xr-frame components with AR functionality in the development tool. Simulation run

    QR code loading

    Note

    When you run the sample project in WeChat Developer Tools for the first time, if plugin permissions haven't been granted, the tool typically prompts that the plugin is unauthorized. You can authorize automatically via WeChat Developer Tools or refer to the Plugin access process.

  2. Click EasyAR Mega Samples to enter the AR scene of the sample project.

    Sample entry

    Note

    If you cannot enter the AR scene of the sample project, it may be because the current device does not support WeChat's VisionKit visual algorithm component. For details, refer to Device limitations.

  3. The on-screen prompt EasyAR Session is initializing indicates WeChat plane detection is initializing.

    Tip

    Ensure testing in well-lit environments, avoiding large areas of solid-color walls or floors.

    Swing steadily left and right facing the ground or other planes to speed up this process.

    Initialization

  4. After initialization is complete, hold the phone vertically to capture a normal real-world view with the camera. When positioning succeeds, the word Found appears in debug information, and the status indicator in the lower-right corner changes from white to green.

    Positioning

Next steps