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 Value | Scene | Meaning of appId |
---|---|---|
1020 | Related Mini Program list in the profile page of an Official Account | Source Official Account |
1035 | Custom menu of an Official Account | Source Official Account |
1036 | Message card shared from an app | Source app |
1037 | Mini Program opened from a Mini Program | Source Mini Program |
1038 | Returned from another Mini Program | Source Mini Program |
1043 | Template message of an Official Account | Source 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.
Type
(callback: (result: CallbackResult) => void) => void
Parameters
CallbackResult
Property | Type | Description |
---|---|---|
path | string | The path for switching the Mini Program to foreground |
query | Record<string, any> | The query parameter for switching the Mini Program to foreground |
referrerInfo | 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.) |
scene | number | Thescene valuefor switching the Mini Program to foreground |
shareTicket | string | The 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.)
Property | Type | Description |
---|---|---|
appId | string | The appId of the source Mini Program, Official Account, or app. |
extraData | Record<string, any> | The data transfered from the source Mini Program, supported when scene=1037 or 1038. |
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.onAppShow | ✔️ |