# ks.onAppShow

更新时间:2025-06-17 15:02:47

监听小程序切前台事件。

# onAppShow(callback: (options: LaunchOptions) => void): void

# 参数

参数 类型 必填 说明
callback (options: LaunchOptions) => void 小程序切前台事件的回调函数
LaunchOptions
属性
属性 类型 说明 最低版本
path string 启动小程序的代码包路径 -
scene string 启动小程序的场景值 -
query Record<string, unknown> 启动小程序的 query 参数 -
referrerInfo ReferrerInfo 进入小程序的来源信息 -
mode 'default' | 'halfPage' 启动小程序的模式 -
showFrom 'schema' | 'other' 打开小程序的来源方式。
'schema' : 用户点击小程序入口
'other' : 其他 (如:后台进前台)
1.39.0
openConfigInfo OpenConfigInfo 扩展信息 -
ReferrerInfo
属性
属性 类型 说明
appId string 来源小程序 appId
extraData Record<string, unknown> 来源小程序传过来的数据
OpenConfigInfo
属性
属性 类型 说明
rewardedAd RewardedAd 激励视频广告信息
interstitialAd InterstitialAd 插屏广告信息
RewardedAd
属性
属性 类型 说明
minDisplayTimestamp number 启动小程序后广告(激励视频、插屏广告)最早的展示时间
InterstitialAd
属性
属性 类型 说明
minDisplayTimestamp number 启动小程序后插屏广告最早的展示时间
minPlayIntervalMs number 启动小程序后插屏广告展示最小间隔时间

# 示例代码

Copyright ©2025, All Rights Reserved