mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-03 23:03:11 +08:00
v10.10.0
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
packageVersion,
|
||||
getCurrentVersionInfo,
|
||||
} from './core';
|
||||
import { CheckResult, ProgressData } from './type';
|
||||
import { CheckResult, ProgressData, PushyTestPayload } from './type';
|
||||
import { PushyContext } from './context';
|
||||
|
||||
export const PushyProvider = ({
|
||||
@@ -262,6 +262,25 @@ export const PushyProvider = ({
|
||||
};
|
||||
}, [checkUpdate, options, dismissError, markSuccess]);
|
||||
|
||||
const parseTestPayload = useCallback(
|
||||
async (code: string) => {
|
||||
let payload: PushyTestPayload;
|
||||
try {
|
||||
payload = JSON.parse(code);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
if (payload && payload.type) {
|
||||
if (payload.type === '__rnPushyVersionHash') {
|
||||
await checkUpdate({ toHash: payload.data });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[checkUpdate],
|
||||
);
|
||||
|
||||
return (
|
||||
<PushyContext.Provider
|
||||
value={{
|
||||
@@ -279,6 +298,7 @@ export const PushyProvider = ({
|
||||
progress,
|
||||
downloadAndInstallApk,
|
||||
getCurrentVersionInfo,
|
||||
parseTestPayload,
|
||||
}}>
|
||||
{children}
|
||||
</PushyContext.Provider>
|
||||
|
||||
Reference in New Issue
Block a user