Skip to content

Commit 6d5ed3e

Browse files
committed
Add guidance on handling conflicts between immediate updates and scan testing in best practices documentation, including code snippet for using beforeCheckUpdate callback to manage update checks.
1 parent ece2ea1 commit 6d5ed3e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

site/pages/docs/bestpractice.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ splits {
8585

8686
</details>
8787

88+
若您用来测试的原生包当前已经有发布的热更版本且更新策略是立即应用,那么和扫码测试之间可能产生策略冲突,比如扫码更新后又立即强制更新到发布版本,对测试带来不便。此时可以考虑在扫码更新之后,利用 beforeCheckUpdate 回调临时禁止更新检查,直到下次启动再恢复。
89+
90+
```js
91+
92+
// isFirstTimeDebug 这个标志位需要 v10.37.0+ 版本,表示当前是扫码热更后的第一次启动
93+
import { isFirstTimeDebug } from 'react-native-update/core';
94+
95+
new Pushy({
96+
beforeCheckUpdate: () => {
97+
if (isFirstTimeDebug) {
98+
// 如果当前是扫码热更后的第一次启动,则跳过热更检查
99+
return false;
100+
}
101+
return true;
102+
},
103+
})
104+
```
105+
88106
万一确实发生线上事故需要回滚的话,先立即对原生包或者整个应用设置暂停热更,然后更改绑定到之前正常的版本,或者利用版本控制系统回滚代码到正常的状态,然后重新生成热更包并推送。
89107

90108
#### 元信息(Meta Info)的使用

0 commit comments

Comments
 (0)