When a mini program is launched, it synchronizes and updates its version, which may cause a waiting period. To reduce this waiting time and improve user experience, the following API is provided to pre-download mini program packages.
Pre-download a single mini program package
API description:
public static void preDownloadPkg(PreDownloadInfo preDownloadInfo, IDownloadCallback callback)
Sample code:
PreDownloadInfo downloadInfo = new PreDownloadInfo("appId");
TmfMiniSDK.preDownloadPkg(downloadInfo, new IDownloadCallback() {
@Override
public void onFinish(DownloadInfo downloadInfo) {
}
@Override
public void onError(DownloadInfo downloadInfo) {
}
});
Pre-download multiple mini program main packages
API description:
public static void preDownloadPkg(List<PreDownloadInfo> preDownloadInfos, IDownloadCallback callback)
Sample code:
PreDownloadInfo downloadInfo = new PreDownloadInfo("appId");
PreDownloadInfo downloadInfo2 = new PreDownloadInfo("appId2");
ArrayList<PreDownloadInfo>infos = new ArrayList<>();
infos.add(downloadInfo);
infos.add(downloadInfo2);
TmfMiniSDK.preDownloadPkg(infos, new IDownloadCallback() {
@Override
public void onFinish(DownloadInfo downloadInfo) {
}
@Override
public void onError(DownloadInfo downloadInfo) {
}
});
Was this page helpful?