mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-19 04:05:08 +08:00
Add custom endpoints
This commit is contained in:
12
lib/index.js
12
lib/index.js
@@ -1,5 +1,6 @@
|
||||
import getHost, { tryBackupDomains } from './getHost';
|
||||
import { tryBackupEndpoints, getCheckUrl, setCustomEndpoints } from './endpoint';
|
||||
import { NativeAppEventEmitter, NativeModules } from 'react-native';
|
||||
export { setCustomEndpoints };
|
||||
|
||||
let Pushy = NativeModules.Pushy;
|
||||
|
||||
@@ -47,7 +48,7 @@ export async function checkUpdate(APPKEY, isRetry) {
|
||||
assertRelease();
|
||||
let resp;
|
||||
try {
|
||||
resp = await fetch(`${getHost()}/checkUpdate/${APPKEY}`, {
|
||||
resp = await fetch(getCheckUrl(APPKEY), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -63,7 +64,7 @@ export async function checkUpdate(APPKEY, isRetry) {
|
||||
if (isRetry) {
|
||||
throw new Error('Could not connect to pushy server');
|
||||
}
|
||||
await tryBackupDomains();
|
||||
await tryBackupEndpoints(APPKEY);
|
||||
return checkUpdate(APPKEY, true);
|
||||
}
|
||||
|
||||
@@ -91,11 +92,6 @@ export async function downloadUpdate(options) {
|
||||
updateUrl: options.pdiffUrl,
|
||||
hashName: options.hash,
|
||||
});
|
||||
} else {
|
||||
await Pushy.downloadUpdate({
|
||||
updateUrl: options.updateUrl,
|
||||
hashName: options.hash,
|
||||
});
|
||||
}
|
||||
return options.hash;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user