react-native-update 10.6.0 → 10.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.6.0",
3
+ "version": "10.7.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/provider.tsx CHANGED
@@ -41,7 +41,19 @@ export const PushyProvider = ({
41
41
  setLastError(undefined);
42
42
  }, []);
43
43
 
44
- const showAlert = useCallback(
44
+ const alertUpdate = useCallback(
45
+ (...args: Parameters<typeof Alert.alert>) => {
46
+ if (
47
+ options.updateStrategy === 'alwaysAlert' ||
48
+ options.updateStrategy === 'alertUpdateAndIgnoreError'
49
+ ) {
50
+ Alert.alert(...args);
51
+ }
52
+ },
53
+ [options.updateStrategy],
54
+ );
55
+
56
+ const alertError = useCallback(
45
57
  (...args: Parameters<typeof Alert.alert>) => {
46
58
  if (options.updateStrategy === 'alwaysAlert') {
47
59
  Alert.alert(...args);
@@ -78,7 +90,7 @@ export const PushyProvider = ({
78
90
  } else if (options.updateStrategy === 'silentAndLater') {
79
91
  return client.switchVersionLater(hash);
80
92
  }
81
- showAlert('提示', '下载完毕,是否立即更新?', [
93
+ alertUpdate('提示', '下载完毕,是否立即更新?', [
82
94
  {
83
95
  text: '下次再说',
84
96
  style: 'cancel',
@@ -96,10 +108,10 @@ export const PushyProvider = ({
96
108
  ]);
97
109
  } catch (e: any) {
98
110
  setLastError(e);
99
- showAlert('更新失败', e.message);
111
+ alertError('更新失败', e.message);
100
112
  }
101
113
  },
102
- [client, options.updateStrategy, showAlert],
114
+ [alertError, client, options.updateStrategy, alertUpdate],
103
115
  );
104
116
 
105
117
  const downloadAndInstallApk = useCallback(
@@ -122,7 +134,7 @@ export const PushyProvider = ({
122
134
  info = await client.checkUpdate();
123
135
  } catch (e: any) {
124
136
  setLastError(e);
125
- showAlert('更新检查失败', e.message);
137
+ alertError('更新检查失败', e.message);
126
138
  return;
127
139
  }
128
140
  if (!info) {
@@ -141,7 +153,7 @@ export const PushyProvider = ({
141
153
  }
142
154
  return;
143
155
  }
144
- showAlert('提示', '您的应用版本已更新,点击更新下载安装新版本', [
156
+ alertUpdate('提示', '您的应用版本已更新,点击更新下载安装新版本', [
145
157
  {
146
158
  text: '更新',
147
159
  onPress: () => {
@@ -161,7 +173,7 @@ export const PushyProvider = ({
161
173
  ) {
162
174
  return downloadUpdate(info);
163
175
  }
164
- showAlert(
176
+ alertUpdate(
165
177
  '提示',
166
178
  '检查到新的版本' + info.name + ',是否下载?\n' + info.description,
167
179
  [
@@ -177,11 +189,12 @@ export const PushyProvider = ({
177
189
  );
178
190
  }
179
191
  }, [
192
+ alertError,
180
193
  client,
181
194
  downloadAndInstallApk,
182
195
  downloadUpdate,
183
196
  options.updateStrategy,
184
- showAlert,
197
+ alertUpdate,
185
198
  ]);
186
199
 
187
200
  const markSuccess = client.markSuccess;
package/src/type.ts CHANGED
@@ -69,7 +69,12 @@ export interface PushyOptions {
69
69
  appKey: string;
70
70
  server?: PushyServerConfig;
71
71
  logger?: UpdateEventsLogger;
72
- updateStrategy?: 'alwaysAlert' | 'silentAndNow' | 'silentAndLater' | null;
72
+ updateStrategy?:
73
+ | 'alwaysAlert'
74
+ | 'alertUpdateAndIgnoreError'
75
+ | 'silentAndNow'
76
+ | 'silentAndLater'
77
+ | null;
73
78
  checkStrategy?: 'onAppStart' | 'onAppResume' | 'both' | null;
74
79
  autoMarkSuccess?: boolean;
75
80
  dismissErrorAfter?: number;