mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-05 15:53:10 +08:00
feat: add getCurrentVersionInfo
This commit is contained in:
@@ -13,6 +13,7 @@ export const defaultContext = {
|
|||||||
dismissError: noop,
|
dismissError: noop,
|
||||||
downloadUpdate: asyncNoop,
|
downloadUpdate: asyncNoop,
|
||||||
downloadAndInstallApk: asyncNoop,
|
downloadAndInstallApk: asyncNoop,
|
||||||
|
getCurrentVersionInfo: () => Promise.resolve({}),
|
||||||
currentHash: '',
|
currentHash: '',
|
||||||
packageVersion: '',
|
packageVersion: '',
|
||||||
};
|
};
|
||||||
@@ -25,6 +26,11 @@ export const PushyContext = createContext<{
|
|||||||
dismissError: () => void;
|
dismissError: () => void;
|
||||||
downloadUpdate: () => Promise<void>;
|
downloadUpdate: () => Promise<void>;
|
||||||
downloadAndInstallApk: (url: string) => Promise<void>;
|
downloadAndInstallApk: (url: string) => Promise<void>;
|
||||||
|
getCurrentVersionInfo: () => Promise<{
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
metaInfo?: string;
|
||||||
|
}>;
|
||||||
currentHash: string;
|
currentHash: string;
|
||||||
packageVersion: string;
|
packageVersion: string;
|
||||||
client?: Pushy;
|
client?: Pushy;
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ import {
|
|||||||
Linking,
|
Linking,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { Pushy } from './client';
|
import { Pushy } from './client';
|
||||||
import { currentVersion, isFirstTime, packageVersion } from './core';
|
import {
|
||||||
|
currentVersion,
|
||||||
|
isFirstTime,
|
||||||
|
packageVersion,
|
||||||
|
getCurrentVersionInfo,
|
||||||
|
} from './core';
|
||||||
import { CheckResult, ProgressData } from './type';
|
import { CheckResult, ProgressData } from './type';
|
||||||
import { PushyContext } from './context';
|
import { PushyContext } from './context';
|
||||||
|
|
||||||
@@ -88,9 +93,9 @@ export const PushyProvider = ({
|
|||||||
}, [client, showAlert, updateInfo]);
|
}, [client, showAlert, updateInfo]);
|
||||||
|
|
||||||
const downloadAndInstallApk = useCallback(
|
const downloadAndInstallApk = useCallback(
|
||||||
(downloadUrl: string) => {
|
async (downloadUrl: string) => {
|
||||||
if (Platform.OS === 'android' && downloadUrl) {
|
if (Platform.OS === 'android' && downloadUrl) {
|
||||||
client.downloadAndInstallApk(downloadUrl, setProgress);
|
await client.downloadAndInstallApk(downloadUrl, setProgress);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[client],
|
[client],
|
||||||
@@ -188,6 +193,7 @@ export const PushyProvider = ({
|
|||||||
currentHash: currentVersion,
|
currentHash: currentVersion,
|
||||||
progress,
|
progress,
|
||||||
downloadAndInstallApk,
|
downloadAndInstallApk,
|
||||||
|
getCurrentVersionInfo,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user