Preset Cards

Updated at:

Download card resources

Method 1: Download the card file from the console. Click Download bin file to download a .zip file.

Method 2: Package the dist/main.zip file from your local card project.

Name the resource

  1. Copy the downloaded file to the resource directory.

  2. Rename the downloaded file to the format Card ID@Card Version, for example, main@1_0_0_0.zip.

    image.png

    Note

    In the future, the console will provide fully named zip packages. You will only need to add them to assets without renaming.

Preset resources

Android

  1. Configure the CubeEngineConfig card engine class.

    /**
    * The path to the local resource package that stores the templates.
    *
    * @param resourcePath - Sets the resource file path.
    */
    public void setResourcePath(String resourcePath) {
                    this.resourcePath = resourcePath;
    }
  2. Set the path to the local Ant Cube Card assets.

    // Purge card data.
    CubeService.instance().destroyEngine();
    CubeEngineConfig config = new CubeEngineConfig();
    // Set the path.
    config.setResourcePath("The path where your resources are located");
    CubeService.instance().initEngine(config, MainApplication.getApplication());
  3. Place the .zip package in the specified path within the assets directory.

iOS

  1. Add the downloaded file to the Bundle.

    Create a new Bundle file. Compress the downloaded .bin file into a .zip package and name it in the format Card ID@Card Version, for example, main1@1_0_0_0.zip. The card requires data from a JSON file. You can use a built-in file or dynamically request the data by calling an API.

    image.png

  2. Import the Bundle into the project and pass the Bundle path when initializing the engine.

    - (void)initEngine {
        // The Bundle path for the local resource template.
        NSString *bundlePath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"MPCubeBundle.bundle"];
        CubeEngineConfig *config = [[CubeEngineConfig alloc] init];
        [config setBundlePath:bundlePath];
        [[CubeService sharedInstance] initWithConfig:config];
    }

HarmonyOS

  1. Configure the CubeEngineConfig card engine class.

    public setResourcePath(resourcePath: string): CubeEngineConfig
    public setResourcePaths(resourcePaths:Array<string>):CubeEngineConfig
  2. Set the path to the local Ant Cube Card rawfile.

    let resourcePaths: Array<string> = ["cube"]
    let config = CubeEngineConfig.obtain()
      .setResourcePath("mp")
      .setResourcePaths(resourcePaths)
    CubeEngine.getInstance().init(config)
  3. Place the .zip package in the specified path within the rawfile directory.