using "expo" (~43.0.2) and "expo-background-fetch" (~10.0.3), my app need to download update from server then save it into storage (AsyncStorage is simply used), but failed. here is my code snippet
TaskManager.defineTask("test", async () => {
const token = await AsyncStorage.getItem("token");
const res = await fetch("...", { headers: { "authorization": token } }) // download data from server
const data = await res.json();
await AsyncStorage.setItem("unread", `${data?.count ?? 0}`);
return BackgroundFetch.BackgroundFetchResult[+data?.count ? "NewData" : "NoData"]
})
I find that the AsyncStorage.getItem
is working because there is a valid server log. However, i cannot retrieve the unread
from AsyncStorage in the app.
can someone help? any suggestion to me?
moreover, i need to call expo.pedometer.getStepCountSync
and scheduleNotificationAsync
during the background task, is it possible?