Offline Package

Last Updated on : 2023-10-13 02:49:30download

A miniapp offline package, which is stored on the local device, includes all the code and resources needed to run a miniapp. When a native app has an integrated offline package, it will prioritize loading this package to run the miniapp. If no offline package exists on the local device, the latest package will be downloaded from the server.

Features

To improve the user experience of miniapps, the offline package comes with the following capabilities:

  • Speed up miniapp startup.

    If an offline package is available on the local device, it will be loaded first to run the miniapp. This saves time by reducing network requests and speeds up the startup of the miniapp.

  • Support compatibility with private deployment.

    When a miniapp is running, it makes requests to servers. If your app is deployed in a private cloud, but the private deployment is not applied to the MiniApp service accordingly, the miniapp cannot run normally. An offline package stored on the local device can be loaded directly to run the miniapp, eliminating the need to retrieve it from the public cloud.

  • Control the auto update policy for miniapps.

    To control the auto update policy of a miniapp and make it stay at a version, you can build an offline package and allow the miniapp to load this package only.

Build offline package

Smart MiniApp IDE will support the auto building of offline packages in the near future. Currently, contact Tuya to help build an offline package for you. To build an offline package, provide Tuya with the following information:

  • The version number of the ThingSmartMiniAppBizBundle component.
  • The version number of the component ThingSmartXXXKitBizBundle that is integrated into your project.
  • The information about miniprogam of the target miniapp.

_miniprograms_info

[
    {
        "id": "xxxxx",// (Required) The miniapp ID.
        "version": "1.2.3",// (Optional) The version number of the miniapp. If you specify a version number, the offline package will be built based on this version number.
        "path": "pages/index/index",// (Optional) The page that provides access to the miniapp.
        "pid": "xxxxx",// The productId with which the panel miniapp is associated. This parameter is required for panel miniapps.
        "onlyloadoffline": "true"// (Optional) Specifies whether to only load an offline package.
    },
    ...
]

_container_version

The version number of the ThingSmartMiniAppBizBundle component that your project depends on.

_dependencies_kits

  • The version number of the ThingSmartXXXKitBizBundle component that your project depends on.
  • All the ThingSmartXXXKitBizBundle components that your project depends on, such as ThingSmartBaseKitBizBundle, ThingSmartBizKitBizBundle, and ThingSmartDeviceKitBizBundle.

Integrate with offline package

The result of the offline package build is a .zip compressed file, named miniapp_offline.zip.

Integrate this compressed file into your project (mainBundle and resourceBundle are applicable) and compile and build the program.

Verify integration result

After the integration of the offline package, you can verify the integration result. Perform the following steps:

  1. Disconnect the mobile phone from the network before you open the miniapp.
  2. Open the miniapp. If it can run normally, the offline package is integrated as expected.