mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-01 13:53:11 +08:00
feat: add restartApp (#488)
This commit is contained in:
@@ -15,6 +15,7 @@ export interface Spec extends TurboModule {
|
||||
getLocalHashInfo(hash: string): Promise<string>;
|
||||
setUuid(uuid: string): Promise<void>;
|
||||
reloadUpdate(options: { hash: string }): Promise<void>;
|
||||
restartApp(): Promise<void>;
|
||||
setNeedUpdate(options: { hash: string }): Promise<void>;
|
||||
markSuccess(): Promise<void>;
|
||||
downloadPatchFromPpk(options: {
|
||||
|
||||
@@ -544,6 +544,9 @@ export class Pushy {
|
||||
delete Pushy.progressHandlers[progressKey];
|
||||
}
|
||||
};
|
||||
restartApp = async () => {
|
||||
return PushyModule.restartApp();
|
||||
};
|
||||
}
|
||||
|
||||
// for international users
|
||||
|
||||
@@ -13,6 +13,7 @@ export const defaultContext = {
|
||||
dismissError: noop,
|
||||
downloadUpdate: asyncNoop,
|
||||
downloadAndInstallApk: asyncNoop,
|
||||
restartApp: asyncNoop,
|
||||
getCurrentVersionInfo: () => Promise.resolve({}),
|
||||
parseTestQrCode: () => false,
|
||||
currentHash: '',
|
||||
@@ -33,6 +34,7 @@ export const UpdateContext = createContext<{
|
||||
metaInfo?: string;
|
||||
}>;
|
||||
parseTestQrCode: (code: string) => boolean;
|
||||
restartApp: () => Promise<void>;
|
||||
currentHash: string;
|
||||
packageVersion: string;
|
||||
client?: Pushy | Cresc;
|
||||
|
||||
@@ -316,6 +316,13 @@ export const UpdateProvider = ({
|
||||
[parseTestPayload],
|
||||
);
|
||||
|
||||
const restartApp = useCallback(
|
||||
async () => {
|
||||
return client.restartApp();
|
||||
},
|
||||
[client],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const parseLinking = (url: string | null) => {
|
||||
if (!url) {
|
||||
@@ -361,6 +368,7 @@ export const UpdateProvider = ({
|
||||
downloadAndInstallApk,
|
||||
getCurrentVersionInfo,
|
||||
parseTestQrCode,
|
||||
restartApp,
|
||||
}}>
|
||||
{children}
|
||||
</UpdateContext.Provider>
|
||||
|
||||
Reference in New Issue
Block a user