fix(0.72): 修复首次拉起微信无回调(冷启动回调丢失)#70
Open
Zemin-Lin wants to merge 1 commit intoreact-native-oh-library:br_rnoh0.72from
Open
fix(0.72): 修复首次拉起微信无回调(冷启动回调丢失)#70Zemin-Lin wants to merge 1 commit intoreact-native-oh-library:br_rnoh0.72from
Zemin-Lin wants to merge 1 commit intoreact-native-oh-library:br_rnoh0.72from
Conversation
Signed-off-by: a1461848339 <1461848339@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
本 PR 修复 Harmony 端
react-native-wechat-lib在首次冷启动拉起微信后无回调的问题。Fixes #(请替换为实际 issue 编号)
Motivation / Root Cause
在冷启动场景中,微信回调
want可能先到达EntryAbility.onCreate/onNewWant,但此时registerApp还未执行,WechatLibTurboModule.wxApi尚未初始化。原逻辑中
handleWant使用可选链直接调用,wxApi == null时会直接返回,导致首个回调丢失。What changed
文件:
harmony/react_native_wechat_lib/src/main/ets/WechatLibTurboModule.ets主要改动:
pendingWants: Array<Want>,用于缓存wxApi初始化前收到的回调。flushPendingWants(),在wxApi初始化后回放缓存回调。handleWant(want):wxApi未初始化:先入队再返回。wxApi已初始化:立即分发。registerApp(...):createWXAPI(appId)后调用flushPendingWants()。Impact scope
仅影响 Harmony 端 WeChat 回调时序处理逻辑(
handleWant/registerApp);不改变已初始化状态下的原有调用行为。
Test Plan
手工验证步骤:
sendAuthRequest或分享能力),触发拉起微信。onResp)是否在首次操作时即可收到。建议关注日志点:
EntryAbility.onCreate/onNewWantWechatLibTurboModule.handleWantWXEventHandler.onRespChecklist
已经在真机设备或模拟器上测试通过
已经与 Android 或 iOS 平台做过效果/功能对比
已经添加了对应 API 的测试用例(如需要)
已经更新了文档(如需要)
更新了 JS/TS 代码 (如有)
I have tested this on a device and a simulator
I have already compared the effects/features with the Android or iOS platforms
I added a test for the API (if applicable)
I have updated the JS/TS (if applicable)
I updated the documentation (if applicable)