Skip to content

Commit 379b863

Browse files
StevenSteven
authored andcommitted
update
1 parent 03c7987 commit 379b863

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

Example/testHotUpdate/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"react-native-paper": "^5.13.1",
2323
"react-native-safe-area-context": "^5.3.0",
2424
"react-native-svg": "^15.11.2",
25-
"react-native-vector-icons": "^10.2.0",
26-
"react-native-update": "file:../../"
25+
"react-native-update": "^10.26.4",
26+
"react-native-vector-icons": "^10.2.0"
2727
},
2828
"devDependencies": {
2929
"@babel/core": "^7.26.0",
@@ -52,4 +52,4 @@
5252
"detox",
5353
"dtrace-provider"
5454
]
55-
}
55+
}

Example/testHotUpdate/src/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function App() {
5353
return (
5454
<View style={styles.container}>
5555
<Text style={styles.welcome}>欢迎使用Pushy热更新服务</Text>
56-
<Text style={styles.welcome}>😁热更新成功</Text>
5756
<View style={{flexDirection: 'row'}}>
5857
<Text>
5958
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示
@@ -224,4 +223,4 @@ export default function Root() {
224223
</PaperProvider>
225224
</UpdateProvider>
226225
);
227-
}
226+
}

android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ android {
9898

9999
buildTypes {
100100
release {
101-
// resValue("string", "pushy_build_time", "${minutesSinceEpoch}")
102-
resValue("string", "pushy_build_time", "29042093")
101+
resValue("string", "pushy_build_time", "${minutesSinceEpoch}")
103102
}
104103
debug {
105104
resValue("string", "pushy_build_time", "0")

src/provider.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ export const UpdateProvider = ({
100100
return false;
101101
}
102102
stateListener.current && stateListener.current.remove();
103+
104+
if (
105+
options.afterDownloadUpdate &&
106+
(await options.afterDownloadUpdate(info)) === false
107+
) {
108+
log('afterDownloadUpdate returned false, skipping');
109+
return false;
110+
}
103111
if (options.updateStrategy === 'silentAndNow') {
104112
client.switchVersion(hash);
105113
return true;
@@ -131,13 +139,7 @@ export const UpdateProvider = ({
131139
return false;
132140
}
133141
},
134-
[
135-
client,
136-
options.updateStrategy,
137-
alertUpdate,
138-
alertError,
139-
throwErrorIfEnabled,
140-
],
142+
[client, options, alertUpdate, alertError, throwErrorIfEnabled],
141143
);
142144

143145
const downloadAndInstallApk = useCallback(
@@ -366,4 +368,4 @@ export const UpdateProvider = ({
366368
};
367369

368370
/** @deprecated Please use `UpdateProvider` instead */
369-
export const PushyProvider = UpdateProvider;
371+
export const PushyProvider = UpdateProvider;

src/type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ export interface ClientOptions {
8888
throwError?: boolean;
8989
beforeCheckUpdate?: () => Promise<boolean>;
9090
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
91+
afterDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
9192
}
9293

9394
export interface UpdateTestPayload {
9495
type: '__rnPushyVersionHash' | string | null;
9596
data: any;
96-
}
97+
}

0 commit comments

Comments
 (0)