Skip to main content

bn.getUpdateManager

getUpdateManager(): UpdateManager

description ObtainGlobally uniqueThe version update manager for managing Mini Program updates.

example

const updateManager = bn.getUpdateManager()

updateManager.onCheckForUpdate(function (res) {
// Callback after requesting new version information
console.log(res.hasUpdate)
})

updateManager.onUpdateReady(function () {
bn.showModal({
title: 'Update tip ',
content: 'The new version is ready, reboot the app? ' ',
success: function (res) {
if (res.confirm) {
// The new version has been downloaded and calls applyUpdate Apply a new version and restart
updateManager.applyUpdate()
}
}
})
})

updateManager.onUpdateFailed(function () {
// New version download failed
})

Returns

UpdateManager

UpdateManager

Interface: UpdateManager

NameTypeDescription
applyUpdate(params?): Promise<void>Force the Mini Program to restart and use the new version. After the new version of the Mini Program has been downloaded (i.e. received onUpdateReady Callback) call.
onCheckForUpdate(callback): voidMonitor the BN background request to check the update results event. BN automatically checks updates when the Mini Program is cold started, without the developer taking the initiative to trigger.
onUpdateReady(callback): voidListening Mini Program has a version update event. Active client trigger download (no developer trigger), download success callback
onUpdateFailed(callback): voidListen for Mini Programs to update failed events. Mini Program has a new version, the client active trigger download (without developer trigger), download failure (may be network reasons, etc.) after the callback

applyUpdate

applyUpdate(params?): Promise<void>

Force the Mini Program to restart and use the new version. After the new version of the Mini Program has been downloaded (i.e. received onUpdateReady Callback) call.

Parameters

NameType
params?Object
params.urlstring

Returns

Promise<void>


onCheckForUpdate

onCheckForUpdate(callback): void

Monitor the BN background request to check the update results event. BN automatically checks updates when the Mini Program is cold started, without the developer taking the initiative to trigger.

Parameters

NameType
callbackOnAppCheckForUpdateCallback

Returns

void


onUpdateReady

onUpdateReady(callback): void

Listening Mini Program has a version update event. Active client trigger download (no developer trigger), download success callback

Parameters

NameType
callbackOnAppUpdateReadyCallback

Returns

void


onUpdateFailed

onUpdateFailed(callback): void

Listen for Mini Programs to update failed events. Mini Program has a new version, the client active trigger download (without developer trigger), download failure (may be network reasons, etc.) after the callback

Parameters

NameType
callbackOnAppUpdateFailedCallback

Returns

void

OnAppCheckForUpdateCallback

Ƭ OnAppCheckForUpdateCallback: (payload: EventAppCheckForUpdatePayload) => void

Type declaration

▸ (payload): void

Parameters

NameType
payloadEventAppCheckForUpdatePayload

Returns

void


EventAppCheckForUpdatePayload

Ƭ EventAppCheckForUpdatePayload: Object

Type declaration

NameTypeDescription
hasUpdatebooleanIndicates whether a new version is available
latestVersion?stringThe version of the latest app.

OnAppUpdateReadyCallback

Ƭ OnAppUpdateReadyCallback: (payload: EventAppCheckForUpdatePayload) => void

Type declaration

▸ (payload): void

Parameters

NameType
payloadEventAppCheckForUpdatePayload

Returns

void


OnAppUpdateFailedCallback

Ƭ OnAppUpdateFailedCallback: () => void

Type declaration

▸ (): void

Returns

void