1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-12-19 04:05:08 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Add custom endpoints

This commit is contained in:
sunnylqm
2020-07-28 23:15:42 +08:00
parent d17eac48f0
commit f110df1206
5 changed files with 101 additions and 69 deletions

View File

@@ -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;
}