Skip to main content
Use this API to listen for events when the Mini Program transitions from foreground to background. The callback triggers at the same time as the onHide() lifecycle method in the app registration.

Parameters

Code Example

AXML with Button

Use Cases

Always remove event listeners when they’re no longer needed using my.offAppHide() to prevent memory leaks.

my.offAppHide

Stop listening for background events

my.onAppShow

Listen for foreground events