Offline Package

Last Updated on : 2023-09-20 08:54:33download

MiniApp offline package is an offline package downloaded to the local system. The package provides all programs and resources that are required to run miniapps. You can integrate the offline package into your native app. Then, when the miniapp is running, it loads the local offline package in priority. If the offline package does not exist, the latest resource package is downloaded from the cloud to run the miniapp.

Features

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

  • Speed up miniapp startup.

    During the process of opening a miniapp, if an offline package exists on the local system, it will be loaded in priority. This reduces the time consumed by network requests and accelerates 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. However, thanks to the capabilities of the offline package, you can download the package of programs and resources required by the miniapp to the local system and enable the miniapp to run.

  • 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 component thingsmart-bizbundle-miniapp.
  • The version number of the business capability component thingsmart-bizbundle-XXXkit that is integrated into your project.
  • The information about miniprogam of the target miniapp.

_miniprograms_info

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

_container_version

The version number of the component thingsmart-bizbundle-miniapp on which the project depends.

_dependencies_kits

  • The version number of the component thingsmart-bizbundle-XXXkit on which the project depends.
  • The details of all components thingsmart-bizbundle-XXXkit on which the project depends, for example, thingsmart-bizbundle-basekit and thingsmart-bizbundle-bizkit.

Integrate with offline package

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

  1. Remove the suffix from this compressed file and rename it to miniapp_offline.
  2. Copy and paste miniapp_offline to the assets directory of the project, 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.