TikTok for Developers

Docs

Update Management

.getUpdateManager

Obtains the globally unique version manager. The TikTok app will automatically check for new versions when the mini game starts, and you do not need to initiate version checks manually.

Parameters

None

Return value

UpdateManager

Version manager object. Repeated calls within the same JavaScript runtime environment will return the same object.

Example

const updateManager = TTMinis.game.getUpdateManager()

UpdateManager

Used to monitor the version check results and the preparation status of the update package, and apply the update once the new version is fully prepared.

.onCheckForUpdate

Listen for the version check completion event. Registering a listener will not actively trigger a new version check.

Function listener

The listener function for the version check completion event.

Listener callback parameters

Object res

Field

Type

Description

hasUpdate


boolean

Indicates whether a new version exists. true means a new version is available, and false means the current version is already the latest one.

Return value

None

Example

const updateManager = TTMinis.game.getUpdateManager()

updateManager.onCheckForUpdate((res) => {
  console.log('Is there a new version available?', res.hasUpdate)
})

.onUpdateReady

Listen for the new version ready event. After receiving this event, you can invoke applyUpdate() to apply the new version.

Function listener

Listens for the new version ready completion event; the callback takes no parameters.

Return value

None

Example

const updateManager = TTMinis.game.getUpdateManager()

updateManager.onUpdateReady(() => {
  console.log('The new version is ready.')
})

.onUpdateFailed

Listen for the new version preparation failure event. Upon receiving this event, the mini game can continue to use the current version.

Function listener

Listening function for new version preparation failure event, with no parameters in the callback.

Return value

None

Example

const updateManager = TTMinis.game.getUpdateManager()

updateManager.onUpdateFailed(() => {
  console.warn('Preparation of the new version failed; continuing to use the current version.')
})

.applyUpdate

Apply the prepared new version and restart the mini game. Please only invoke this after receiving onUpdateReady, and save the game progress and other business status that needs to be restored before the invocation.

Parameter

None

Return value

None

Example

const updateManager = TTMinis.game.getUpdateManager()

updateManager.onUpdateReady(() => {
  // Save game progress and apply the update after obtaining user confirmation.
  updateManager.applyUpdate()
})

Notes

  • You should register the version management-related listeners before the game entry and the loading of the first scene.
  • Avoid registering the same type of listener multiple times in initialization logic that spans multiple scenarios or runs repeatedly.
  • You should avoid restarting the game immediately during real-time matches, payment processing or reward settlement; users may be prompted to update at an appropriate opportunity.
Was this document helpful?
TikTok for Developers