adds update functionality

This commit is contained in:
2024-12-13 04:02:43 +01:00
parent f50420978e
commit b0154802e3
2 changed files with 25 additions and 5 deletions
+23 -4
View File
@@ -1,7 +1,26 @@
import React from "react";
import React, { useEffect } from "react";
import { Slot } from "expo-router";
import * as Updates from "expo-updates";
import {Slot} from "expo-router";
export default function App() {
return <Slot/>;
}
const checkForUpdates = async () => {
try {
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
console.log("Update verfügbar. Wird heruntergeladen...");
await Updates.fetchUpdateAsync();
await Updates.reloadAsync(); // App neu starten, um Update anzuwenden
} else {
console.log("Keine Updates verfügbar.");
}
} catch (e) {
console.error("Fehler beim Prüfen auf Updates:", e);
}
};
useEffect(() => {
checkForUpdates(); // Nur einmal beim Laden der App ausführen
}, []);
return <Slot />;
}
+2 -1
View File
@@ -60,7 +60,8 @@
"policy": "appVersion"
},
"updates": {
"url": "https://u.expo.dev/6c7ada5a-fcc7-4d36-a056-c542c6d13dac"
"url": "https://u.expo.dev/6c7ada5a-fcc7-4d36-a056-c542c6d13dac",
"enabled": true
}
}
}