react-native-update 10.25.3 → 10.26.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 +1 -1
- package/src/client.ts +11 -6
- package/src/context.ts +1 -1
- package/src/provider.tsx +3 -2
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -82,13 +82,13 @@ export class Pushy {
|
|
|
82
82
|
};
|
|
83
83
|
})();
|
|
84
84
|
|
|
85
|
-
constructor(options: ClientOptions) {
|
|
85
|
+
constructor(options: ClientOptions, clientType?: 'Pushy' | 'Cresc') {
|
|
86
86
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
87
87
|
if (!options.appKey) {
|
|
88
88
|
throw new Error('appKey is required');
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
this.clientType =
|
|
91
|
+
this.clientType = clientType || 'Pushy';
|
|
92
92
|
this.options.server = SERVER_PRESETS[this.clientType];
|
|
93
93
|
this.setOptions(options);
|
|
94
94
|
if (isRolledBack) {
|
|
@@ -226,10 +226,11 @@ export class Pushy {
|
|
|
226
226
|
// @ts-ignore
|
|
227
227
|
delete fetchBody.buildTime;
|
|
228
228
|
}
|
|
229
|
+
const stringifyBody = JSON.stringify(fetchBody);
|
|
229
230
|
// harmony fetch body is not string
|
|
230
231
|
let body: any = fetchBody;
|
|
231
232
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
232
|
-
body =
|
|
233
|
+
body = stringifyBody;
|
|
233
234
|
}
|
|
234
235
|
const fetchPayload = {
|
|
235
236
|
method: 'POST',
|
|
@@ -243,13 +244,13 @@ export class Pushy {
|
|
|
243
244
|
try {
|
|
244
245
|
this.report({
|
|
245
246
|
type: 'checking',
|
|
246
|
-
message: this.options.appKey + ': ' +
|
|
247
|
+
message: this.options.appKey + ': ' + stringifyBody,
|
|
247
248
|
});
|
|
248
249
|
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
|
249
250
|
} catch (e: any) {
|
|
250
251
|
this.report({
|
|
251
252
|
type: 'errorChecking',
|
|
252
|
-
message:
|
|
253
|
+
message: `Can not connect to update server: ${e.message}. Trying backup endpoints.`,
|
|
253
254
|
});
|
|
254
255
|
const backupEndpoints = await this.getBackupEndpoints();
|
|
255
256
|
if (backupEndpoints) {
|
|
@@ -520,4 +521,8 @@ export class Pushy {
|
|
|
520
521
|
}
|
|
521
522
|
|
|
522
523
|
// for international users
|
|
523
|
-
export class Cresc extends Pushy {
|
|
524
|
+
export class Cresc extends Pushy {
|
|
525
|
+
constructor(options: ClientOptions) {
|
|
526
|
+
super(options, 'Cresc');
|
|
527
|
+
}
|
|
528
|
+
}
|
package/src/context.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const defaultContext = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const UpdateContext = createContext<{
|
|
23
|
-
checkUpdate: () => Promise<void>;
|
|
23
|
+
checkUpdate: () => Promise<void | CheckResult>;
|
|
24
24
|
switchVersion: () => Promise<void>;
|
|
25
25
|
switchVersionLater: () => Promise<void>;
|
|
26
26
|
markSuccess: () => void;
|
package/src/provider.tsx
CHANGED
|
@@ -188,7 +188,7 @@ export const UpdateProvider = ({
|
|
|
188
188
|
} else {
|
|
189
189
|
Linking.openURL(downloadUrl);
|
|
190
190
|
}
|
|
191
|
-
return;
|
|
191
|
+
return info;
|
|
192
192
|
}
|
|
193
193
|
alertUpdate('提示', '您的应用版本已更新,点击更新下载安装新版本', [
|
|
194
194
|
{
|
|
@@ -209,7 +209,7 @@ export const UpdateProvider = ({
|
|
|
209
209
|
options.updateStrategy === 'silentAndLater'
|
|
210
210
|
) {
|
|
211
211
|
downloadUpdate(info);
|
|
212
|
-
return;
|
|
212
|
+
return info;
|
|
213
213
|
}
|
|
214
214
|
alertUpdate(
|
|
215
215
|
'提示',
|
|
@@ -226,6 +226,7 @@ export const UpdateProvider = ({
|
|
|
226
226
|
],
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
|
+
return info;
|
|
229
230
|
},
|
|
230
231
|
[
|
|
231
232
|
client,
|