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

Parameters

Callback Parameters

The callback receives the same parameters as the onShow() lifecycle method:

Code Example

Use Cases

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

my.offAppShow

Stop listening for foreground events

my.onAppHide

Listen for background events