1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 10:21:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

fallback for all

This commit is contained in:
sunnylqm
2025-05-21 11:46:40 +08:00
parent 2cf7336b6a
commit e5424591d1

View File

@@ -109,11 +109,11 @@ export const assertDev = (matter: string) => {
return true; return true;
}; };
export const isAndroid70AndBelow = () => { // export const isAndroid70AndBelow = () => {
// android 7.0 and below devices do not support letsencrypt cert // // android 7.0 and below devices do not support letsencrypt cert
// https://letsencrypt.org/2023/07/10/cross-sign-expiration/ // // https://letsencrypt.org/2023/07/10/cross-sign-expiration/
return Platform.OS === 'android' && Platform.Version <= 24; // return Platform.OS === 'android' && Platform.Version <= 24;
}; // };
export const enhancedFetch = async ( export const enhancedFetch = async (
url: string, url: string,
@@ -121,10 +121,7 @@ export const enhancedFetch = async (
) => { ) => {
return fetch(url, params).catch(e => { return fetch(url, params).catch(e => {
log('fetch error', url, e); log('fetch error', url, e);
if (isAndroid70AndBelow()) { log('trying fallback to http');
log(`try fallback to http because android version: ${Platform.Version}`); return fetch(url.replace('https', 'http'), params);
return fetch(url.replace('https', 'http'), params);
}
throw e;
}); });
}; };