Skip to main content
Version: Next

Taro.onAppShow(callback)

Listens on the event that Mini Program is switched to foreground. The callback timing for this event is consistent with that of App.onShow.

Scenes that Return Valid referrerInfo

Scene ValueSceneMeaning of appId
1020Related Mini Program list in the profile page of an Official AccountSource Official Account
1035Custom menu of an Official AccountSource Official Account
1036Message card shared from an appSource app
1037Mini Program opened from a Mini ProgramSource Mini Program
1038Returned from another Mini ProgramSource Mini Program
1043Template message of an Official AccountSource Official Account

Note

In some versions, when there is no referrerInfo, the value undefined is returned. You can use options.referrerInfo && options.referrerInfo.appId to make a judgment.

Reference

Type

(callback: (result: CallbackResult) => void) => void

Parameters

CallbackResult

PropertyTypeDescription
pathstringThe path for switching the Mini Program to foreground
queryRecord<string, any>The query parameter for switching the Mini Program to foreground
referrerInfoResultReferrerInfoThe source information. This is returned when a user enters the Mini Program from another Mini Program, Official Account, or app. Otherwise, is returned. (see the Note below for details.)
scenenumberThescene valuefor switching the Mini Program to foreground
shareTicketstringThe shareTicket. See Obtaining More Forwarded Information for details.

ResultReferrerInfo

The source information. This is returned when a user enters the Mini Program from another Mini Program, Official Account, or app. Otherwise, {} is returned. (see the Note below for details.)

PropertyTypeDescription
appIdstringThe appId of the source Mini Program, Official Account, or app.
extraDataRecord<string, any>The data transfered from the source Mini Program, supported when scene=1037 or 1038.

API Support

APIWeChat Mini-ProgramH5React Native
Taro.onAppShow✔️